Merge branch 'master' into hl7org_dstu21

This commit is contained in:
jamesagnew 2015-12-15 20:33:31 -05:00
commit 6ac62a5b46
56 changed files with 825 additions and 284 deletions

1
.gitignore vendored
View File

@ -16,6 +16,7 @@ nohup.out
tmp.txt tmp.txt
*.hprof *.hprof
tmp.txt tmp.txt
ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamString/
# Vagrant stuff. # Vagrant stuff.
.vagrant .vagrant

View File

@ -192,7 +192,7 @@ class ModelScanner {
Map<String, Class<? extends IBaseResource>> resourceTypes = myNameToResourceType; Map<String, Class<? extends IBaseResource>> resourceTypes = myNameToResourceType;
myVersionTypes = scanVersionPropertyFile(theDatatypes, resourceTypes, myVersion); myVersionTypes = scanVersionPropertyFile(theDatatypes, resourceTypes, myVersion);
// toScan.add(DateDt.class); // toScan.add(DateDt.class);
// toScan.add(CodeDt.class); // toScan.add(CodeDt.class);
// toScan.add(DecimalDt.class); // toScan.add(DecimalDt.class);

View File

@ -109,22 +109,26 @@ public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefini
} else { } else {
nextDef = theClassToElementDefinitions.get(next); nextDef = theClassToElementDefinitions.get(next);
BaseRuntimeElementDefinition<?> nextDefForChoice = nextDef; BaseRuntimeElementDefinition<?> nextDefForChoice = nextDef;
if (nextDef instanceof IRuntimeDatatypeDefinition) { /*
IRuntimeDatatypeDefinition nextDefDatatype = (IRuntimeDatatypeDefinition) nextDef; * In HAPI 1.3 the following applied:
if (nextDefDatatype.getProfileOf() != null) { * Elements which are called foo[x] and have a choice which is a profiled datatype must use the
/* * unprofiled datatype as the element name. E.g. if foo[x] allows markdown as a datatype, it calls the
* Elements which are called foo[x] and have a choice which is a profiled datatype must use the * element fooString when encoded, because markdown is a profile of string. This is according to the
* unprofiled datatype as the element name. E.g. if foo[x] allows markdown as a datatype, it calls the * FHIR spec
* element fooString when encoded, because markdown is a profile of string. This is according to the *
* FHIR spec * As of HAPI 1.4 this has been disabled after conversation with Grahame. It appears
*/ * that it is not correct behaviour.
nextDefForChoice = null; */
nonPreferred = true; // if (nextDef instanceof IRuntimeDatatypeDefinition) {
Class<? extends IBaseDatatype> profileType = nextDefDatatype.getProfileOf(); // IRuntimeDatatypeDefinition nextDefDatatype = (IRuntimeDatatypeDefinition) nextDef;
BaseRuntimeElementDefinition<?> elementDef = theClassToElementDefinitions.get(profileType); // if (nextDefDatatype.getProfileOf() != null) {
elementName = getElementName() + StringUtils.capitalize(elementDef.getName()); // nextDefForChoice = null;
} // nonPreferred = true;
} // Class<? extends IBaseDatatype> profileType = nextDefDatatype.getProfileOf();
// BaseRuntimeElementDefinition<?> elementDef = theClassToElementDefinitions.get(profileType);
// elementName = getElementName() + StringUtils.capitalize(elementDef.getName());
// }
// }
if (nextDefForChoice != null) { if (nextDefForChoice != null) {
elementName = getElementName() + StringUtils.capitalize(nextDefForChoice.getName()); elementName = getElementName() + StringUtils.capitalize(nextDefForChoice.getName());
} }

View File

@ -26,6 +26,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeSet;
import org.apache.commons.lang3.text.WordUtils; import org.apache.commons.lang3.text.WordUtils;
import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBase;
@ -34,6 +35,7 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
import ca.uhn.fhir.model.api.ExtensionDt; import ca.uhn.fhir.model.api.ExtensionDt;
import ca.uhn.fhir.model.api.IDatatype; import ca.uhn.fhir.model.api.IDatatype;
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt; import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
import ca.uhn.fhir.model.primitive.CodeDt;
public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildDefinition { public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildDefinition {
@ -153,13 +155,8 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD
myDatatypeToAttributeName = new HashMap<Class<? extends IBase>, String>(); myDatatypeToAttributeName = new HashMap<Class<? extends IBase>, String>();
myDatatypeToDefinition = new HashMap<Class<? extends IBase>, BaseRuntimeElementDefinition<?>>(); myDatatypeToDefinition = new HashMap<Class<? extends IBase>, BaseRuntimeElementDefinition<?>>();
// for (theContext.get)
for (BaseRuntimeElementDefinition<?> next : theClassToElementDefinitions.values()) { for (BaseRuntimeElementDefinition<?> next : theClassToElementDefinitions.values()) {
if (next instanceof IRuntimeDatatypeDefinition) { if (next instanceof IRuntimeDatatypeDefinition) {
// if (next.getName().equals("CodeableConcept")) {
// System.out.println();
// }
myDatatypeToDefinition.put(next.getImplementingClass(), next); myDatatypeToDefinition.put(next.getImplementingClass(), next);
@ -178,7 +175,7 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD
* type. * type.
*/ */
if (!qualifiedName.startsWith("ca.uhn.fhir.model")) { if (!qualifiedName.startsWith("ca.uhn.fhir.model")) {
if (!qualifiedName.startsWith("org.hl7.fhir.instance.model")) { if (!qualifiedName.startsWith("org.hl7.fhir")) {
continue; continue;
} }
} }
@ -198,12 +195,6 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD
myAttributeNameToDefinition = datatypeAttributeNameToDefinition; myAttributeNameToDefinition = datatypeAttributeNameToDefinition;
// for (Entry<String, BaseRuntimeElementDefinition<?>> next : myAttributeNameToDefinition.entrySet()) {
// @SuppressWarnings("unchecked")
// Class<? extends IDatatype> type = (Class<? extends IDatatype>) next.getValue().getImplementingClass();
// myDatatypeToDefinition.put(type, next.getValue());
// }
/* /*
* Resource reference - The correct name is 'valueReference' in DSTU2 and 'valueResource' in DSTU1 * Resource reference - The correct name is 'valueReference' in DSTU2 and 'valueResource' in DSTU1
*/ */

View File

@ -1,5 +1,8 @@
package ca.uhn.fhir.model.api; package ca.uhn.fhir.model.api;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
/* /*
@ -32,9 +35,9 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
*/ */
public class Include { public class Include {
private final boolean myImmutable;
private boolean myRecurse; private boolean myRecurse;
private String myValue; private String myValue;
private boolean myImmutable;
/** /**
* Constructor for <b>non-recursive</b> include * Constructor for <b>non-recursive</b> include
@ -44,10 +47,11 @@ public class Include {
*/ */
public Include(String theValue) { public Include(String theValue) {
myValue = theValue; myValue = theValue;
myImmutable = false;
} }
/** /**
* Constructor for <b>non-recursive</b> include * Constructor for an include
* *
* @param theValue * @param theValue
* The <code>_include</code> value, e.g. "Patient:name" * The <code>_include</code> value, e.g. "Patient:name"
@ -57,6 +61,21 @@ public class Include {
public Include(String theValue, boolean theRecurse) { public Include(String theValue, boolean theRecurse) {
myValue = theValue; myValue = theValue;
myRecurse = theRecurse; myRecurse = theRecurse;
myImmutable = false;
}
/**
* Constructor for an include
*
* @param theValue
* The <code>_include</code> value, e.g. "Patient:name"
* @param theRecurse
* Should the include recurse
*/
public Include(String theValue, boolean theRecurse, boolean theImmutable) {
myValue = theValue;
myRecurse = theRecurse;
myImmutable = theImmutable;
} }
/** /**
@ -73,22 +92,6 @@ public class Include {
return new Include(myValue, true); return new Include(myValue, true);
} }
public String getValue() {
return myValue;
}
/**
* See the note on equality on the {@link Include class documentation}
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (myRecurse ? 1231 : 1237);
result = prime * result + ((myValue == null) ? 0 : myValue.hashCode());
return result;
}
/** /**
* See the note on equality on the {@link Include class documentation} * See the note on equality on the {@link Include class documentation}
*/ */
@ -117,6 +120,73 @@ public class Include {
return true; return true;
} }
/**
* Returns the portion of the value before the first colon
*/
public String getParamType() {
int firstColon = myValue.indexOf(':');
if (firstColon == -1 || firstColon == myValue.length() - 1) {
return null;
}
return myValue.substring(0, firstColon);
}
/**
* Returns the portion of the value after the first colon but before the second colon
*/
public String getParamName() {
int firstColon = myValue.indexOf(':');
if (firstColon == -1 || firstColon == myValue.length() - 1) {
return null;
}
int secondColon = myValue.indexOf(':', firstColon + 1);
if (secondColon != -1) {
return myValue.substring(firstColon + 1, secondColon);
} else {
return myValue.substring(firstColon + 1);
}
}
/**
* Returns the portion of the string after the second colon, or null if there are not two colons in the value.
*/
public String getParamTargetType() {
int firstColon = myValue.indexOf(':');
if (firstColon == -1 || firstColon == myValue.length() - 1) {
return null;
}
int secondColon = myValue.indexOf(':', firstColon + 1);
if (secondColon != -1) {
return myValue.substring(secondColon + 1);
} else {
return null;
}
}
public String getValue() {
return myValue;
}
/**
* See the note on equality on the {@link Include class documentation}
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (myRecurse ? 1231 : 1237);
result = prime * result + ((myValue == null) ? 0 : myValue.hashCode());
return result;
}
/**
* Is this object {@link #toLocked() locked}?
*/
public boolean isLocked() {
return myImmutable;
}
public boolean isRecurse() { public boolean isRecurse() {
return myRecurse; return myRecurse;
} }
@ -132,12 +202,14 @@ public class Include {
myValue = theValue; myValue = theValue;
} }
/**
* Return a new
*/
public Include toLocked() { public Include toLocked() {
Include retVal = new Include(myValue, myRecurse); Include retVal = new Include(myValue, myRecurse, true);
retVal.myImmutable = true;
return retVal; return retVal;
} }
@Override @Override
public String toString() { public String toString() {
ToStringBuilder builder = new ToStringBuilder(this); ToStringBuilder builder = new ToStringBuilder(this);
@ -145,4 +217,56 @@ public class Include {
builder.append("recurse", myRecurse); builder.append("recurse", myRecurse);
return builder.toString(); return builder.toString();
} }
/**
* Creates and returns a new copy of this Include with the given type. The following table shows what will be
* returned:
* <table>
* <tr>
* <th>Initial Contents</th>
* <th>theResourceType</th>
* <th>Output</th>
* </tr>
* <tr>
* <td>Patient:careProvider</th>
* <th>Organization</th>
* <th>Patient:careProvider:Organization</th>
* </tr>
* <tr>
* <td>Patient:careProvider:Practitioner</th>
* <th>Organization</th>
* <th>Patient:careProvider:Organization</th>
* </tr>
* <tr>
* <td>Patient</th>
* <th>(any)</th>
* <th>{@link IllegalStateException}</th>
* </tr>
* </table>
*
* @param theResourceType
* The resource type (e.g. "Organization")
* @return A new copy of the include. Note that if this include is {@link #toLocked() locked}, the returned include
* will be too
*/
public Include withType(String theResourceType) {
StringBuilder b = new StringBuilder();
String paramType = getParamType();
String paramName = getParamName();
if (isBlank(paramType) || isBlank(paramName)) {
throw new IllegalStateException("This include does not contain a value in the format [ResourceType]:[paramName]");
}
b.append(paramType);
b.append(":");
b.append(paramName);
if (isNotBlank(theResourceType)) {
b.append(':');
b.append(theResourceType);
}
Include retVal = new Include(b.toString(), myRecurse, myImmutable);
return retVal;
}
} }

View File

@ -28,6 +28,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeSet;
import javax.xml.stream.events.StartElement; import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent; import javax.xml.stream.events.XMLEvent;

View File

@ -853,10 +853,10 @@ public class GenericClient extends BaseClient implements IGenericClient {
} }
@Override @Override
public IDeleteTyped resource(IResource theResource) { public IDeleteTyped resource(IBaseResource theResource) {
Validate.notNull(theResource, "theResource can not be null"); Validate.notNull(theResource, "theResource can not be null");
IdDt id = theResource.getId(); IIdType id = theResource.getIdElement();
Validate.notNull(id, "theResource.getId() can not be null"); Validate.notNull(id, "theResource.getIdElement() can not be null");
if (id.hasResourceType() == false || id.hasIdPart() == false) { if (id.hasResourceType() == false || id.hasIdPart() == false) {
throw new IllegalArgumentException("theResource.getId() must contain a resource type and logical ID at a minimum (e.g. Patient/1234), found: " + id.getValue()); throw new IllegalArgumentException("theResource.getId() must contain a resource type and logical ID at a minimum (e.g. Patient/1234), found: " + id.getValue());
} }

View File

@ -1,5 +1,25 @@
package ca.uhn.fhir.rest.client.interceptor; package ca.uhn.fhir.rest.client.interceptor;
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPOutputStream;

View File

@ -3,8 +3,6 @@ package ca.uhn.fhir.rest.gclient;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.instance.model.api.IIdType;
import ca.uhn.fhir.model.api.IResource;
/* /*
* #%L * #%L
* HAPI FHIR - Core Library * HAPI FHIR - Core Library
@ -27,7 +25,7 @@ import ca.uhn.fhir.model.api.IResource;
public interface IDelete { public interface IDelete {
IDeleteTyped resource(IResource theResource); IDeleteTyped resource(IBaseResource theResource);
IDeleteTyped resourceById(IIdType theId); IDeleteTyped resourceById(IIdType theId);

View File

@ -1,5 +1,25 @@
package ca.uhn.fhir.jaxrs.server; package ca.uhn.fhir.jaxrs.server;
/*
* #%L
* HAPI FHIR JAX-RS Server
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.io.IOException; import java.io.IOException;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.lang.reflect.Method; import java.lang.reflect.Method;

View File

@ -1,5 +1,25 @@
package ca.uhn.fhir.jaxrs.server; package ca.uhn.fhir.jaxrs.server;
/*
* #%L
* HAPI FHIR JAX-RS Server
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;

View File

@ -1,5 +1,25 @@
package ca.uhn.fhir.jaxrs.server; package ca.uhn.fhir.jaxrs.server;
/*
* #%L
* HAPI FHIR JAX-RS Server
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;

View File

@ -1,5 +1,25 @@
package ca.uhn.fhir.jaxrs.server; package ca.uhn.fhir.jaxrs.server;
/*
* #%L
* HAPI FHIR JAX-RS Server
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.util.Collections; import java.util.Collections;

View File

@ -1,5 +1,25 @@
package ca.uhn.fhir.jaxrs.server.interceptor; package ca.uhn.fhir.jaxrs.server.interceptor;
/*
* #%L
* HAPI FHIR JAX-RS Server
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.io.IOException; import java.io.IOException;
import javax.interceptor.AroundInvoke; import javax.interceptor.AroundInvoke;

View File

@ -1,5 +1,25 @@
package ca.uhn.fhir.jaxrs.server.interceptor; package ca.uhn.fhir.jaxrs.server.interceptor;
/*
* #%L
* HAPI FHIR JAX-RS Server
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import javax.ejb.ApplicationException; import javax.ejb.ApplicationException;
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException; import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;

View File

@ -1,5 +1,25 @@
package ca.uhn.fhir.jaxrs.server.util; package ca.uhn.fhir.jaxrs.server.util;
/*
* #%L
* HAPI FHIR JAX-RS Server
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;

View File

@ -1,5 +1,25 @@
package ca.uhn.fhir.jaxrs.server.util; package ca.uhn.fhir.jaxrs.server.util;
/*
* #%L
* HAPI FHIR JAX-RS Server
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.Reader; import java.io.Reader;

View File

@ -1,5 +1,25 @@
package ca.uhn.fhir.jaxrs.server.util; package ca.uhn.fhir.jaxrs.server.util;
/*
* #%L
* HAPI FHIR JAX-RS Server
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.io.IOException; import java.io.IOException;
import java.io.StringWriter; import java.io.StringWriter;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;

View File

@ -436,6 +436,7 @@
<skip-hib4>true</skip-hib4> <skip-hib4>true</skip-hib4>
</properties> </properties>
</profile> </profile>
<!--
<profile> <profile>
<id>DIST</id> <id>DIST</id>
<build> <build>
@ -448,9 +449,13 @@
<target>SCRIPT</target> <target>SCRIPT</target>
<skip>${skip-hib4}</skip> <skip>${skip-hib4}</skip>
</configuration> </configuration>
<!-- This needs to be uncommented in order for this plugin to work with Hibernate 4.3+ (as of hibernate4-maven-plugin version 1.0.5) --> <dependencies>
<dependencies> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <dependency>
<version>${hibernate_version}</version> </dependency> </dependencies> <groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate_version}</version>
</dependency>
</dependencies>
<executions> <executions>
<execution> <execution>
<id>o10g</id> <id>o10g</id>
@ -501,6 +506,7 @@
</plugins> </plugins>
</build> </build>
</profile> </profile>
-->
</profiles> </profiles>
</project> </project>

View File

@ -1079,13 +1079,15 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
return retVal; return retVal;
} }
protected IBaseResource toResource(BaseHasResource theEntity, boolean theForHistoryOperation) { @Override
public IBaseResource toResource(BaseHasResource theEntity, boolean theForHistoryOperation) {
RuntimeResourceDefinition type = myContext.getResourceDefinition(theEntity.getResourceType()); RuntimeResourceDefinition type = myContext.getResourceDefinition(theEntity.getResourceType());
return toResource(type.getImplementingClass(), theEntity, theForHistoryOperation); return toResource(type.getImplementingClass(), theEntity, theForHistoryOperation);
} }
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected <R extends IBaseResource> R toResource(Class<R> theResourceType, BaseHasResource theEntity, boolean theForHistoryOperation) { public <R extends IBaseResource> R toResource(Class<R> theResourceType, BaseHasResource theEntity, boolean theForHistoryOperation) {
String resourceText = null; String resourceText = null;
switch (theEntity.getEncoding()) { switch (theEntity.getEncoding()) {
case JSON: case JSON:

View File

@ -33,10 +33,7 @@ import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException; import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import javax.persistence.TypedQuery; import javax.persistence.TypedQuery;
@ -97,9 +94,6 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
@Autowired @Autowired
private DaoConfig myDaoConfig; private DaoConfig myDaoConfig;
@PersistenceContext(type = PersistenceContextType.TRANSACTION)
protected EntityManager myEntityManager;
@Autowired @Autowired
protected PlatformTransactionManager myPlatformTransactionManager; protected PlatformTransactionManager myPlatformTransactionManager;

View File

@ -1,5 +1,25 @@
package ca.uhn.fhir.jpa.dao; package ca.uhn.fhir.jpa.dao;
/*
* #%L
* HAPI FHIR JPA Server
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import static org.apache.commons.lang3.StringUtils.isNotBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -1,5 +1,8 @@
package ca.uhn.fhir.jpa.dao; package ca.uhn.fhir.jpa.dao;
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.IResource;
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum; import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
@ -40,5 +43,9 @@ public interface IDao {
} }
}; };
IBaseResource toResource(BaseHasResource theEntity, boolean theForHistoryOperation);
<R extends IBaseResource> R toResource(Class<R> theResourceType, BaseHasResource theEntity, boolean theForHistoryOperation);
} }

View File

@ -1,5 +1,7 @@
package ca.uhn.fhir.jpa.dao; package ca.uhn.fhir.jpa.dao;
import static org.apache.commons.lang3.StringUtils.defaultString;
/* /*
* #%L * #%L
* HAPI FHIR JPA Server * HAPI FHIR JPA Server
@ -1322,7 +1324,7 @@ public class SearchBuilder {
* *
* @param theLastUpdated * @param theLastUpdated
*/ */
private HashSet<Long> loadReverseIncludes(Collection<Long> theMatches, Set<Include> theRevIncludes, boolean theReverseMode, EverythingModeEnum theEverythingModeEnum, DateRangeParam theLastUpdated) { private HashSet<Long> loadReverseIncludes(Collection<Long> theMatches, Set<Include> theRevIncludes, boolean theReverseMode, DateRangeParam theLastUpdated) {
if (theMatches.size() == 0) { if (theMatches.size() == 0) {
return new HashSet<Long>(); return new HashSet<Long>();
} }
@ -1378,19 +1380,18 @@ public class SearchBuilder {
if (myContext.getVersion().getVersion() == FhirVersionEnum.DSTU1) { if (myContext.getVersion().getVersion() == FhirVersionEnum.DSTU1) {
paths = Collections.singletonList(nextInclude.getValue()); paths = Collections.singletonList(nextInclude.getValue());
} else { } else {
int colonIdx = nextInclude.getValue().indexOf(':'); String resType = nextInclude.getParamType();
if (colonIdx < 2) { if (isBlank(resType)) {
continue; continue;
} }
String resType = nextInclude.getValue().substring(0, colonIdx);
RuntimeResourceDefinition def = myContext.getResourceDefinition(resType); RuntimeResourceDefinition def = myContext.getResourceDefinition(resType);
if (def == null) { if (def == null) {
ourLog.warn("Unknown resource type in include/revinclude=" + nextInclude.getValue()); ourLog.warn("Unknown resource type in include/revinclude=" + nextInclude.getValue());
continue; continue;
} }
String paramName = nextInclude.getValue().substring(colonIdx + 1); String paramName = nextInclude.getParamName();
RuntimeSearchParam param = def.getSearchParam(paramName); RuntimeSearchParam param = isNotBlank(paramName) ? def.getSearchParam(paramName) : null;
if (param == null) { if (param == null) {
ourLog.warn("Unknown param name in include/revinclude=" + nextInclude.getValue()); ourLog.warn("Unknown param name in include/revinclude=" + nextInclude.getValue());
continue; continue;
@ -1399,11 +1400,20 @@ public class SearchBuilder {
paths = param.getPathsSplit(); paths = param.getPathsSplit();
} }
String targetResourceType = defaultString(nextInclude.getParamTargetType(), null);
for (String nextPath : paths) { for (String nextPath : paths) {
String sql = "SELECT r FROM ResourceLink r WHERE r.mySourcePath = :src_path AND r." + searchFieldName + " IN (:target_pids)"; String sql;
if (targetResourceType != null) {
sql = "SELECT r FROM ResourceLink r WHERE r.mySourcePath = :src_path AND r." + searchFieldName + " IN (:target_pids) AND r.myTargetResourceType = :target_resource_type";
} else {
sql = "SELECT r FROM ResourceLink r WHERE r.mySourcePath = :src_path AND r." + searchFieldName + " IN (:target_pids)";
}
TypedQuery<ResourceLink> q = myEntityManager.createQuery(sql, ResourceLink.class); TypedQuery<ResourceLink> q = myEntityManager.createQuery(sql, ResourceLink.class);
q.setParameter("src_path", nextPath); q.setParameter("src_path", nextPath);
q.setParameter("target_pids", nextRoundMatches); q.setParameter("target_pids", nextRoundMatches);
if (targetResourceType != null) {
q.setParameter("target_resource_type", targetResourceType);
}
List<ResourceLink> results = q.getResultList(); List<ResourceLink> results = q.getResultList();
for (ResourceLink resourceLink : results) { for (ResourceLink resourceLink : results) {
if (theReverseMode) { if (theReverseMode) {
@ -1595,7 +1605,7 @@ public class SearchBuilder {
final Set<Long> revIncludedPids; final Set<Long> revIncludedPids;
if (theParams.getEverythingMode() == null) { if (theParams.getEverythingMode() == null) {
if (theParams.getRevIncludes() != null && theParams.getRevIncludes().isEmpty() == false) { if (theParams.getRevIncludes() != null && theParams.getRevIncludes().isEmpty() == false) {
revIncludedPids = loadReverseIncludes(pids, theParams.getRevIncludes(), true, null, lu); revIncludedPids = loadReverseIncludes(pids, theParams.getRevIncludes(), true, lu);
} else { } else {
revIncludedPids = new HashSet<Long>(); revIncludedPids = new HashSet<Long>();
} }
@ -1623,7 +1633,7 @@ public class SearchBuilder {
// Load includes // Load includes
pidsSubList = new ArrayList<Long>(pidsSubList); pidsSubList = new ArrayList<Long>(pidsSubList);
revIncludedPids.addAll(loadReverseIncludes(pidsSubList, theParams.getIncludes(), false, null, theParams.getLastUpdated())); revIncludedPids.addAll(loadReverseIncludes(pidsSubList, theParams.getIncludes(), false, theParams.getLastUpdated()));
// Execute the query and make sure we return distinct results // Execute the query and make sure we return distinct results
List<IBaseResource> resources = new ArrayList<IBaseResource>(); List<IBaseResource> resources = new ArrayList<IBaseResource>();

View File

@ -36,6 +36,7 @@ import javax.persistence.Table;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.search.annotations.Field; import org.hibernate.search.annotations.Field;
@Entity @Entity
@ -64,6 +65,11 @@ public class ResourceLink implements Serializable {
@Column(name = "SRC_RESOURCE_ID", insertable = false, updatable = false, nullable = false) @Column(name = "SRC_RESOURCE_ID", insertable = false, updatable = false, nullable = false)
private Long mySourceResourcePid; private Long mySourceResourcePid;
@Column(name = "SOURCE_RESOURCE_TYPE", nullable=false, length=ResourceTable.RESTYPE_LEN)
@ColumnDefault("''") // TODO: remove this (it's only here for simplifying upgrades of 1.3 -> 1.4)
@Field()
private String mySourceResourceType;
@ManyToOne(optional = false, fetch=FetchType.LAZY) @ManyToOne(optional = false, fetch=FetchType.LAZY)
@JoinColumn(name = "TARGET_RESOURCE_ID", referencedColumnName = "RES_ID", nullable = false) @JoinColumn(name = "TARGET_RESOURCE_ID", referencedColumnName = "RES_ID", nullable = false)
private ResourceTable myTargetResource; private ResourceTable myTargetResource;
@ -71,18 +77,21 @@ public class ResourceLink implements Serializable {
@Column(name = "TARGET_RESOURCE_ID", insertable = false, updatable = false, nullable = false) @Column(name = "TARGET_RESOURCE_ID", insertable = false, updatable = false, nullable = false)
@Field() @Field()
private Long myTargetResourcePid; private Long myTargetResourcePid;
@Column(name = "TARGET_RESOURCE_TYPE", nullable=false, length=ResourceTable.RESTYPE_LEN)
@ColumnDefault("''") // TODO: remove this (it's only here for simplifying upgrades of 1.3 -> 1.4)
@Field()
private String myTargetResourceType;
public ResourceLink() { public ResourceLink() {
super(); super();
} }
public ResourceLink(String theSourcePath, ResourceTable theSourceResource, ResourceTable theTargetResource) { public ResourceLink(String theSourcePath, ResourceTable theSourceResource, ResourceTable theTargetResource) {
super(); super();
mySourcePath = theSourcePath; setSourcePath(theSourcePath);
mySourceResource = theSourceResource; setSourceResource(theSourceResource);
mySourceResourcePid = theSourceResource.getId(); setTargetResource(theTargetResource);
myTargetResource = theTargetResource;
myTargetResourcePid = theTargetResource.getId();
} }
@Override @Override
@ -140,12 +149,14 @@ public class ResourceLink implements Serializable {
public void setSourceResource(ResourceTable theSourceResource) { public void setSourceResource(ResourceTable theSourceResource) {
mySourceResource = theSourceResource; mySourceResource = theSourceResource;
mySourceResourcePid = theSourceResource.getId(); mySourceResourcePid = theSourceResource.getId();
mySourceResourceType = theSourceResource.getResourceType();
} }
public void setTargetResource(ResourceTable theTargetResource) { public void setTargetResource(ResourceTable theTargetResource) {
Validate.notNull(theTargetResource); Validate.notNull(theTargetResource);
myTargetResource = theTargetResource; myTargetResource = theTargetResource;
myTargetResourcePid = theTargetResource.getId(); myTargetResourcePid = theTargetResource.getId();
myTargetResourceType = theTargetResource.getResourceType();
} }
@Override @Override

View File

@ -1,5 +1,25 @@
package ca.uhn.fhir.jpa.provider; package ca.uhn.fhir.jpa.provider;
/*
* #%L
* HAPI FHIR JPA Server
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;

View File

@ -4,7 +4,9 @@ import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.not;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import java.util.List; import java.util.List;
@ -14,9 +16,8 @@ import javax.servlet.http.HttpServletRequest;
import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.instance.model.api.IIdType;
import org.junit.Test; import org.junit.Test;
import ca.uhn.fhir.jpa.dao.FhirSearchDao;
import ca.uhn.fhir.jpa.dao.SearchParameterMap;
import ca.uhn.fhir.jpa.dao.FhirSearchDao.Suggestion; import ca.uhn.fhir.jpa.dao.FhirSearchDao.Suggestion;
import ca.uhn.fhir.jpa.dao.SearchParameterMap;
import ca.uhn.fhir.model.dstu2.resource.Device; import ca.uhn.fhir.model.dstu2.resource.Device;
import ca.uhn.fhir.model.dstu2.resource.Media; import ca.uhn.fhir.model.dstu2.resource.Media;
import ca.uhn.fhir.model.dstu2.resource.Observation; import ca.uhn.fhir.model.dstu2.resource.Observation;

View File

@ -1430,27 +1430,45 @@ public class FhirResourceDaoDstu2SearchNoFtTest extends BaseJpaDstu2Test {
{ {
Organization org = new Organization(); Organization org = new Organization();
org.getNameElement().setValue(methodName + "_O1Parent"); org.getNameElement().setValue(methodName + "_O1Parent");
parentOrgId = myOrganizationDao.create(org).getId(); parentOrgId = myOrganizationDao.create(org).getId().toUnqualifiedVersionless();
} }
IIdType orgId;
IIdType patientId;
{ {
Organization org = new Organization(); Organization org = new Organization();
org.getNameElement().setValue(methodName + "_O1"); org.getNameElement().setValue(methodName + "_O1");
org.setPartOf(new ResourceReferenceDt(parentOrgId)); org.setPartOf(new ResourceReferenceDt(parentOrgId));
IIdType orgId = myOrganizationDao.create(org).getId(); orgId = myOrganizationDao.create(org).getId().toUnqualifiedVersionless();
Patient patient = new Patient(); Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001"); patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("Tester_" + methodName + "_P1").addGiven("Joe"); patient.addName().addFamily("Tester_" + methodName + "_P1").addGiven("Joe");
patient.getManagingOrganization().setReference(orgId); patient.getManagingOrganization().setReference(orgId);
myPatientDao.create(patient); patient.addCareProvider().setReference(orgId);
patientId = myPatientDao.create(patient).getId().toUnqualifiedVersionless();
} }
IIdType practId2;
{
Practitioner pract = new Practitioner();
pract.getName().addFamily(methodName + "_PRACT1");
practId2 = myPractitionerDao.create(pract).getId().toUnqualifiedVersionless();
}
IIdType patientId2;
{ {
Patient patient = new Patient(); Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("002"); patient.addIdentifier().setSystem("urn:system").setValue("002");
patient.addName().addFamily("Tester_" + methodName + "_P2").addGiven("John"); patient.addName().addFamily("Tester_" + methodName + "_P2").addGiven("John");
myPatientDao.create(patient); patient.addCareProvider().setReference(practId2);
patientId2 = myPatientDao.create(patient).getId().toUnqualifiedVersionless();
} }
{
// Typed include
SearchParameterMap params = new SearchParameterMap();
params.addInclude(Patient.INCLUDE_CAREPROVIDER.withType("Practitioner"));
List<IIdType> ids = toUnqualifiedVersionlessIds(myPatientDao.search(params));
assertThat(ids, containsInAnyOrder(patientId, patientId2, practId2));
}
{ {
// No includes // No includes
SearchParameterMap params = new SearchParameterMap(); SearchParameterMap params = new SearchParameterMap();
@ -1527,6 +1545,13 @@ public class FhirResourceDaoDstu2SearchNoFtTest extends BaseJpaDstu2Test {
assertEquals(1, patients.size()); assertEquals(1, patients.size());
assertEquals(Patient.class, patients.get(0).getClass()); assertEquals(Patient.class, patients.get(0).getClass());
} }
{
// Untyped include
SearchParameterMap params = new SearchParameterMap();
params.addInclude(Patient.INCLUDE_CAREPROVIDER);
List<IIdType> ids = toUnqualifiedVersionlessIds(myPatientDao.search(params));
assertThat(ids, containsInAnyOrder(orgId, patientId, patientId2, practId2));
}
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")

View File

@ -1,5 +1,25 @@
package ca.uhn.fhir.rest.server.provider; package ca.uhn.fhir.rest.server.provider;
/*
* #%L
* HAPI FHIR Structures - DSTU1 (FHIR v0.80)
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;

View File

@ -65,7 +65,7 @@ public class BaseDateTimeDtTest {
DateTimeDt dt = DateTimeDt.withCurrentTime(); DateTimeDt dt = DateTimeDt.withCurrentTime();
String str = dt.getValueAsString(); String str = dt.getValueAsString();
char offset = str.charAt(19); char offset = str.charAt(19);
if (offset != '+' && offset != '-') { if (offset != '+' && offset != '-' && offset != 'Z') {
fail("No timezone provided: " + str); fail("No timezone provided: " + str);
} }
} }
@ -75,7 +75,7 @@ public class BaseDateTimeDtTest {
InstantDt dt = InstantDt.withCurrentTime(); InstantDt dt = InstantDt.withCurrentTime();
String str = dt.getValueAsString(); String str = dt.getValueAsString();
char offset = str.charAt(23); char offset = str.charAt(23);
if (offset != '+' && offset != '-') { if (offset != '+' && offset != '-' && offset != 'Z') {
fail("No timezone provided: " + str); fail("No timezone provided: " + str);
} }
} }

View File

@ -20,9 +20,6 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import net.sf.json.JSON;
import net.sf.json.JSONSerializer;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.hamcrest.core.IsNot; import org.hamcrest.core.IsNot;
import org.hamcrest.core.StringContains; import org.hamcrest.core.StringContains;
@ -30,7 +27,6 @@ import org.hamcrest.text.StringContainsInOrder;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import ca.uhn.fhir.context.ConfigurationException; import ca.uhn.fhir.context.ConfigurationException;
@ -68,6 +64,7 @@ import ca.uhn.fhir.model.dstu.resource.ValueSet.DefineConcept;
import ca.uhn.fhir.model.dstu.valueset.AddressUseEnum; import ca.uhn.fhir.model.dstu.valueset.AddressUseEnum;
import ca.uhn.fhir.model.dstu.valueset.IdentifierUseEnum; import ca.uhn.fhir.model.dstu.valueset.IdentifierUseEnum;
import ca.uhn.fhir.model.dstu.valueset.NarrativeStatusEnum; import ca.uhn.fhir.model.dstu.valueset.NarrativeStatusEnum;
import ca.uhn.fhir.model.primitive.CodeDt;
import ca.uhn.fhir.model.primitive.DateDt; import ca.uhn.fhir.model.primitive.DateDt;
import ca.uhn.fhir.model.primitive.DateTimeDt; import ca.uhn.fhir.model.primitive.DateTimeDt;
import ca.uhn.fhir.model.primitive.DecimalDt; import ca.uhn.fhir.model.primitive.DecimalDt;
@ -76,6 +73,8 @@ import ca.uhn.fhir.model.primitive.InstantDt;
import ca.uhn.fhir.model.primitive.StringDt; import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.model.primitive.XhtmlDt; import ca.uhn.fhir.model.primitive.XhtmlDt;
import ca.uhn.fhir.narrative.INarrativeGenerator; import ca.uhn.fhir.narrative.INarrativeGenerator;
import net.sf.json.JSON;
import net.sf.json.JSONSerializer;
public class JsonParserTest { public class JsonParserTest {
private static FhirContext ourCtx; private static FhirContext ourCtx;
@ -1318,11 +1317,14 @@ public class JsonParserTest {
public void testSimpleResourceEncode() throws IOException { public void testSimpleResourceEncode() throws IOException {
String xmlString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general.xml"), Charset.forName("UTF-8")); String xmlString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general.xml"), Charset.forName("UTF-8"));
Patient obs = ourCtx.newXmlParser().parseResource(Patient.class, xmlString); IParser parser = ourCtx.newXmlParser();
parser.setParserErrorHandler(new StrictErrorHandler());
Patient obs = parser.parseResource(Patient.class, xmlString);
List<ExtensionDt> undeclaredExtensions = obs.getContact().get(0).getName().getFamily().get(0).getUndeclaredExtensions(); List<ExtensionDt> undeclaredExtensions = obs.getContact().get(0).getName().getFamily().get(0).getUndeclaredExtensions();
ExtensionDt undeclaredExtension = undeclaredExtensions.get(0); ExtensionDt undeclaredExtension = undeclaredExtensions.get(0);
assertEquals("http://hl7.org/fhir/Profile/iso-21090#qualifier", undeclaredExtension.getUrl()); assertEquals("http://hl7.org/fhir/Profile/iso-21090#qualifier", undeclaredExtension.getUrl());
assertEquals("VV", ((CodeDt)undeclaredExtension.getValue()).getValue());
ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToWriter(obs, new OutputStreamWriter(System.out)); ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToWriter(obs, new OutputStreamWriter(System.out));
@ -1341,7 +1343,7 @@ public class JsonParserTest {
ourLog.info("Expected: {}", exp); ourLog.info("Expected: {}", exp);
ourLog.info("Actual : {}", act); ourLog.info("Actual : {}", act);
assertEquals(exp, act); assertEquals("\nExpected: " + exp + "\nActual : " + act, exp, act);
} }
@ -1376,8 +1378,7 @@ public class JsonParserTest {
ourLog.info("Expected: {}", exp); ourLog.info("Expected: {}", exp);
ourLog.info("Actual : {}", act); ourLog.info("Actual : {}", act);
assertEquals(exp, act); assertEquals("\nExpected: " + exp + "\nActual : " + act, exp, act);
} }
@Test @Test

View File

@ -1,7 +1,10 @@
package ca.uhn.fhir.rest.server; package ca.uhn.fhir.rest.server;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.*; import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -51,56 +54,21 @@ import ca.uhn.fhir.util.PortUtil;
public class IncludeTest { public class IncludeTest {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static FhirContext ourCtx;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(IncludeTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(IncludeTest.class);
private static int ourPort; private static int ourPort;
private static Server ourServer; private static Server ourServer;
private static FhirContext ourCtx;
@Test @Test
public void testNoIncludes() throws Exception { public void testBadInclude() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello"); HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello&_include=foo&_include=baz");
HttpResponse status = ourClient.execute(httpGet);
String responseContent = IOUtils.toString(status.getEntity().getContent());
IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(1, bundle.size());
Patient p = bundle.getResources(Patient.class).get(0);
assertEquals(0, p.getName().size());
assertEquals("Hello", p.getId().getIdPart());
}
@Test
public void testOneInclude() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello&_include=foo");
HttpResponse status = ourClient.execute(httpGet);
String responseContent = IOUtils.toString(status.getEntity().getContent());
IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(1, bundle.size());
Patient p = bundle.getResources(Patient.class).get(0);
assertEquals(1, p.getName().size());
assertEquals("Hello", p.getId().getIdPart());
assertEquals("foo", p.getName().get(0).getFamilyFirstRep().getValue());
}
// @Test
public void testMixedContainedAndNonContained() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/DiagnosticReport?_query=stitchedInclude&_pretty=true");
HttpResponse status = ourClient.execute(httpGet); HttpResponse status = ourClient.execute(httpGet);
assertEquals(400, status.getStatusLine().getStatusCode());
String responseContent = IOUtils.toString(status.getEntity().getContent()); String responseContent = IOUtils.toString(status.getEntity().getContent());
IOUtils.closeQuietly(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
ourLog.info(responseContent); ourLog.info(responseContent);
assertThat(responseContent, containsString("Invalid _include parameter value"));
assertEquals(200, status.getStatusLine().getStatusCode());
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(4, bundle.size());
} }
@Test @Test
@ -128,6 +96,32 @@ public class IncludeTest {
} }
@Test
public void testIIncludedResourcesNonContainedInDeclaredExtension() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=declaredExtInclude&_pretty=true");
HttpResponse status = ourClient.execute(httpGet);
String responseContent = IOUtils.toString(status.getEntity().getContent());
IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
ourLog.info(responseContent);
assertEquals(4, bundle.size());
assertEquals(new IdDt("Patient/p1"), bundle.toListOfResources().get(0).getId().toUnqualifiedVersionless());
assertEquals(new IdDt("Patient/p2"), bundle.toListOfResources().get(1).getId().toUnqualifiedVersionless());
assertEquals(new IdDt("Organization/o1"), bundle.toListOfResources().get(2).getId().toUnqualifiedVersionless());
assertEquals(new IdDt("Organization/o2"), bundle.toListOfResources().get(3).getId().toUnqualifiedVersionless());
Patient p1 = (Patient) bundle.toListOfResources().get(0);
assertEquals(0, p1.getContained().getContainedResources().size());
Patient p2 = (Patient) bundle.toListOfResources().get(1);
assertEquals(0, p2.getContained().getContainedResources().size());
}
@Test @Test
public void testIIncludedResourcesNonContainedInExtension() throws Exception { public void testIIncludedResourcesNonContainedInExtension() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=extInclude&_pretty=true"); HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=extInclude&_pretty=true");
@ -179,29 +173,81 @@ public class IncludeTest {
} }
@Test @Test
public void testIIncludedResourcesNonContainedInDeclaredExtension() throws Exception { public void testIncludeWithType() {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=declaredExtInclude&_pretty=true"); assertEquals("Patient:careProvider:Practitioner", new Include("Patient:careProvider", true).withType("Practitioner").getValue());
assertEquals(true, new Include("Patient:careProvider", true).withType("Practitioner").isRecurse());
assertEquals(false, new Include("Patient:careProvider:Organization", true).withType("Practitioner").isLocked());
assertEquals("Practitioner", new Include("Patient:careProvider", true).withType("Practitioner").getParamTargetType());
assertEquals(null, new Include("Patient:careProvider", true).getParamTargetType());
assertEquals("Patient:careProvider:Practitioner", new Include("Patient:careProvider:Organization", true).withType("Practitioner").getValue());
assertEquals(true, new Include("Patient:careProvider:Organization", true).toLocked().withType("Practitioner").isLocked());
try {
new Include("").withType("Patient");
fail();
} catch (IllegalStateException e) {
// good
}
try {
new Include("Patient").withType("Patient");
fail();
} catch (IllegalStateException e) {
// good
}
try {
new Include("Patient:").withType("Patient");
fail();
} catch (IllegalStateException e) {
// good
}
}
// @Test
public void testMixedContainedAndNonContained() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/DiagnosticReport?_query=stitchedInclude&_pretty=true");
HttpResponse status = ourClient.execute(httpGet);
String responseContent = IOUtils.toString(status.getEntity().getContent());
IOUtils.closeQuietly(status.getEntity().getContent());
ourLog.info(responseContent);
assertEquals(200, status.getStatusLine().getStatusCode());
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(4, bundle.size());
}
@Test
public void testNoIncludes() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello");
HttpResponse status = ourClient.execute(httpGet); HttpResponse status = ourClient.execute(httpGet);
String responseContent = IOUtils.toString(status.getEntity().getContent()); String responseContent = IOUtils.toString(status.getEntity().getContent());
IOUtils.closeQuietly(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode()); assertEquals(200, status.getStatusLine().getStatusCode());
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent); Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(1, bundle.size());
ourLog.info(responseContent); Patient p = bundle.getResources(Patient.class).get(0);
assertEquals(0, p.getName().size());
assertEquals("Hello", p.getId().getIdPart());
}
assertEquals(4, bundle.size()); @Test
assertEquals(new IdDt("Patient/p1"), bundle.toListOfResources().get(0).getId().toUnqualifiedVersionless()); public void testOneInclude() throws Exception {
assertEquals(new IdDt("Patient/p2"), bundle.toListOfResources().get(1).getId().toUnqualifiedVersionless()); HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello&_include=foo");
assertEquals(new IdDt("Organization/o1"), bundle.toListOfResources().get(2).getId().toUnqualifiedVersionless()); HttpResponse status = ourClient.execute(httpGet);
assertEquals(new IdDt("Organization/o2"), bundle.toListOfResources().get(3).getId().toUnqualifiedVersionless()); String responseContent = IOUtils.toString(status.getEntity().getContent());
IOUtils.closeQuietly(status.getEntity().getContent());
Patient p1 = (Patient) bundle.toListOfResources().get(0); assertEquals(200, status.getStatusLine().getStatusCode());
assertEquals(0, p1.getContained().getContainedResources().size()); Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(1, bundle.size());
Patient p2 = (Patient) bundle.toListOfResources().get(1);
assertEquals(0, p2.getContained().getContainedResources().size());
Patient p = bundle.getResources(Patient.class).get(0);
assertEquals(1, p.getName().size());
assertEquals("Hello", p.getId().getIdPart());
assertEquals("foo", p.getName().get(0).getFamilyFirstRep().getValue());
} }
@Test @Test
@ -226,18 +272,6 @@ public class IncludeTest {
} }
@Test
public void testBadInclude() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello&_include=foo&_include=baz");
HttpResponse status = ourClient.execute(httpGet);
assertEquals(400, status.getStatusLine().getStatusCode());
String responseContent = IOUtils.toString(status.getEntity().getContent());
IOUtils.closeQuietly(status.getEntity().getContent());
ourLog.info(responseContent);
assertThat(responseContent, containsString("Invalid _include parameter value"));
}
@AfterClass @AfterClass
public static void afterClass() throws Exception { public static void afterClass() throws Exception {
ourServer.stop(); ourServer.stop();
@ -268,27 +302,20 @@ public class IncludeTest {
} }
@ResourceDef(name = "Patient") public static void main(String[] args) {
public static class ExtPatient extends Patient {
@Child(name = "secondOrg")
@Extension(url = "http://foo#secondOrg", definedLocally = false, isModifier = false)
private ResourceReferenceDt mySecondOrg;
@Override Organization org = new Organization();
public boolean isEmpty() { org.setId("Organization/65546");
return super.isEmpty() && ElementUtil.isEmpty(mySecondOrg); org.getName().setValue("Contained Test Organization");
}
public ResourceReferenceDt getSecondOrg() { Patient patient = new Patient();
if (mySecondOrg == null) { patient.setId("Patient/1333");
mySecondOrg = new ResourceReferenceDt(); patient.addIdentifier("urn:mrns", "253345");
} patient.getManagingOrganization().setResource(patient);
return mySecondOrg;
}
public void setSecondOrg(ResourceReferenceDt theSecondOrg) { System.out.println(FhirContext.forDstu1().newXmlParser().setPrettyPrint(true).encodeResourceToString(patient));
mySecondOrg = theSecondOrg;
} patient.getManagingOrganization().getReference();
} }
@ -345,11 +372,10 @@ public class IncludeTest {
*/ */
public static class DummyPatientResourceProvider implements IResourceProvider { public static class DummyPatientResourceProvider implements IResourceProvider {
@Search(queryName = "normalInclude") @Search(queryName = "containedInclude")
public List<Patient> normalInclude() { public List<Patient> containedInclude() {
Organization o1 = new Organization(); Organization o1 = new Organization();
o1.getName().setValue("o1"); o1.getName().setValue("o1");
o1.setId("o1");
Patient p1 = new Patient(); Patient p1 = new Patient();
p1.setId("p1"); p1.setId("p1");
@ -364,25 +390,6 @@ public class IncludeTest {
return Arrays.asList(p1, p2); return Arrays.asList(p1, p2);
} }
@Search(queryName = "extInclude")
public List<Patient> extInclude() {
Organization o1 = new Organization();
o1.getName().setValue("o1");
o1.setId("o1");
Patient p1 = new Patient();
p1.setId("p1");
p1.addIdentifier().setLabel("p1");
p1.addUndeclaredExtension(false, "http://foo", new ResourceReferenceDt(o1));
Patient p2 = new Patient();
p2.setId("p2");
p2.addIdentifier().setLabel("p2");
p2.addUndeclaredExtension(false, "http://foo", new ResourceReferenceDt(o1));
return Arrays.asList(p1, p2);
}
@Search(queryName = "declaredExtInclude") @Search(queryName = "declaredExtInclude")
public List<ExtPatient> declaredExtInclude() { public List<ExtPatient> declaredExtInclude() {
Organization o1 = new Organization(); Organization o1 = new Organization();
@ -407,20 +414,21 @@ public class IncludeTest {
return Arrays.asList(p1, p2); return Arrays.asList(p1, p2);
} }
@Search(queryName = "containedInclude") @Search(queryName = "extInclude")
public List<Patient> containedInclude() { public List<Patient> extInclude() {
Organization o1 = new Organization(); Organization o1 = new Organization();
o1.getName().setValue("o1"); o1.getName().setValue("o1");
o1.setId("o1");
Patient p1 = new Patient(); Patient p1 = new Patient();
p1.setId("p1"); p1.setId("p1");
p1.addIdentifier().setLabel("p1"); p1.addIdentifier().setLabel("p1");
p1.getManagingOrganization().setResource(o1); p1.addUndeclaredExtension(false, "http://foo", new ResourceReferenceDt(o1));
Patient p2 = new Patient(); Patient p2 = new Patient();
p2.setId("p2"); p2.setId("p2");
p2.addIdentifier().setLabel("p2"); p2.addIdentifier().setLabel("p2");
p2.getManagingOrganization().setResource(o1); p2.addUndeclaredExtension(false, "http://foo", new ResourceReferenceDt(o1));
return Arrays.asList(p1, p2); return Arrays.asList(p1, p2);
} }
@ -449,22 +457,48 @@ public class IncludeTest {
return Patient.class; return Patient.class;
} }
@Search(queryName = "normalInclude")
public List<Patient> normalInclude() {
Organization o1 = new Organization();
o1.getName().setValue("o1");
o1.setId("o1");
Patient p1 = new Patient();
p1.setId("p1");
p1.addIdentifier().setLabel("p1");
p1.getManagingOrganization().setResource(o1);
Patient p2 = new Patient();
p2.setId("p2");
p2.addIdentifier().setLabel("p2");
p2.getManagingOrganization().setResource(o1);
return Arrays.asList(p1, p2);
}
} }
public static void main(String[] args) { @ResourceDef(name = "Patient")
public static class ExtPatient extends Patient {
@Child(name = "secondOrg")
@Extension(url = "http://foo#secondOrg", definedLocally = false, isModifier = false)
private ResourceReferenceDt mySecondOrg;
Organization org = new Organization(); public ResourceReferenceDt getSecondOrg() {
org.setId("Organization/65546"); if (mySecondOrg == null) {
org.getName().setValue("Contained Test Organization"); mySecondOrg = new ResourceReferenceDt();
}
return mySecondOrg;
}
Patient patient = new Patient(); @Override
patient.setId("Patient/1333"); public boolean isEmpty() {
patient.addIdentifier("urn:mrns", "253345"); return super.isEmpty() && ElementUtil.isEmpty(mySecondOrg);
patient.getManagingOrganization().setResource(patient); }
System.out.println(FhirContext.forDstu1().newXmlParser().setPrettyPrint(true).encodeResourceToString(patient)); public void setSecondOrg(ResourceReferenceDt theSecondOrg) {
mySecondOrg = theSecondOrg;
patient.getManagingOrganization().getReference(); }
} }

View File

@ -2,7 +2,7 @@ package ca.uhn.fhir.model.dstu21;
/* /*
* #%L * #%L
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) * HAPI FHIR Structures - DSTU2.1 (FHIR v1.1.x)
* %% * %%
* Copyright (C) 2014 - 2015 University Health Network * Copyright (C) 2014 - 2015 University Health Network
* %% * %%

View File

@ -6,7 +6,7 @@ import ca.uhn.fhir.model.primitive.IntegerDt;
/* /*
* #%L * #%L
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) * HAPI FHIR Structures - DSTU2.1 (FHIR v1.1.x)
* %% * %%
* Copyright (C) 2014 - 2015 University Health Network * Copyright (C) 2014 - 2015 University Health Network
* %% * %%

View File

@ -2,7 +2,7 @@ package ca.uhn.fhir.model.dstu21.composite;
/* /*
* #%L * #%L
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) * HAPI FHIR Structures - DSTU2.1 (FHIR v1.1.x)
* %% * %%
* Copyright (C) 2014 - 2015 University Health Network * Copyright (C) 2014 - 2015 University Health Network
* %% * %%

View File

@ -2,7 +2,7 @@ package ca.uhn.fhir.model.dstu21.composite;
/* /*
* #%L * #%L
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) * HAPI FHIR Structures - DSTU2.1 (FHIR v1.1.x)
* %% * %%
* Copyright (C) 2014 - 2015 University Health Network * Copyright (C) 2014 - 2015 University Health Network
* %% * %%

View File

@ -5,7 +5,7 @@ import ca.uhn.fhir.model.dstu21.composite.QuantityDt;
/* /*
* #%L * #%L
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) * HAPI FHIR Structures - DSTU2.1 (FHIR v1.1.x)
* %% * %%
* Copyright (C) 2014 - 2015 University Health Network * Copyright (C) 2014 - 2015 University Health Network
* %% * %%

View File

@ -6,7 +6,7 @@ import ca.uhn.fhir.model.primitive.IntegerDt;
/* /*
* #%L * #%L
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) * HAPI FHIR Structures - DSTU2.1 (FHIR v1.1.x)
* %% * %%
* Copyright (C) 2014 - 2015 University Health Network * Copyright (C) 2014 - 2015 University Health Network
* %% * %%

View File

@ -5,7 +5,7 @@ import ca.uhn.fhir.model.dstu21.composite.QuantityDt;
/* /*
* #%L * #%L
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) * HAPI FHIR Structures - DSTU2.1 (FHIR v1.1.x)
* %% * %%
* Copyright (C) 2014 - 2015 University Health Network * Copyright (C) 2014 - 2015 University Health Network
* %% * %%

View File

@ -5,7 +5,7 @@ import ca.uhn.fhir.model.dstu21.composite.QuantityDt;
/* /*
* #%L * #%L
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) * HAPI FHIR Structures - DSTU2.1 (FHIR v1.1.x)
* %% * %%
* Copyright (C) 2014 - 2015 University Health Network * Copyright (C) 2014 - 2015 University Health Network
* %% * %%

View File

@ -18,7 +18,7 @@ package ca.uhn.fhir.model.dstu21.composite;
/* /*
* #%L * #%L
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) * HAPI FHIR Structures - DSTU2.1 (FHIR v1.1.x)
* %% * %%
* Copyright (C) 2014 - 2015 University Health Network * Copyright (C) 2014 - 2015 University Health Network
* %% * %%

View File

@ -18,7 +18,7 @@ package ca.uhn.fhir.model.dstu21.composite;
/* /*
* #%L * #%L
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) * HAPI FHIR Structures - DSTU2.1 (FHIR v1.1.x)
* %% * %%
* Copyright (C) 2014 - 2015 University Health Network * Copyright (C) 2014 - 2015 University Health Network
* %% * %%

View File

@ -7,7 +7,7 @@ import ca.uhn.fhir.model.dstu21.valueset.QuantityComparatorEnum;
/* /*
* #%L * #%L
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) * HAPI FHIR Structures - DSTU2.1 (FHIR v1.1.x)
* %% * %%
* Copyright (C) 2014 - 2015 University Health Network * Copyright (C) 2014 - 2015 University Health Network
* %% * %%

View File

@ -2,7 +2,7 @@ package ca.uhn.fhir.model.dstu21.resource;
/* /*
* #%L * #%L
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) * HAPI FHIR Structures - DSTU2.1 (FHIR v1.1.x)
* %% * %%
* Copyright (C) 2014 - 2015 University Health Network * Copyright (C) 2014 - 2015 University Health Network
* %% * %%

View File

@ -2,7 +2,7 @@ package ca.uhn.fhir.rest.server.provider.dstu21;
/* /*
* #%L * #%L
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) * HAPI FHIR Structures - DSTU2.1 (FHIR v1.1.x)
* %% * %%
* Copyright (C) 2014 - 2015 University Health Network * Copyright (C) 2014 - 2015 University Health Network
* %% * %%

View File

@ -2,7 +2,7 @@ package ca.uhn.fhir.rest.server.provider.dstu21;
/* /*
* #%L * #%L
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) * HAPI FHIR Structures - DSTU2.1 (FHIR v1.1.x)
* %% * %%
* Copyright (C) 2014 - 2015 University Health Network * Copyright (C) 2014 - 2015 University Health Network
* %% * %%

View File

@ -2,7 +2,7 @@ package ca.uhn.fhir.rest.server.provider.dstu21;
/* /*
* #%L * #%L
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) * HAPI FHIR Structures - DSTU2.1 (FHIR v1.1.x)
* %% * %%
* Copyright (C) 2014 - 2015 University Health Network * Copyright (C) 2014 - 2015 University Health Network
* %% * %%

View File

@ -125,7 +125,7 @@ public class XmlParserDstu21Test {
assertArrayEquals(new byte[] { 1, 2, 3, 4 }, bin.getContent()); assertArrayEquals(new byte[] { 1, 2, 3, 4 }, bin.getContent());
} }
@Test @Test
public void testEncodeEmptyBinary() { public void testEncodeEmptyBinary() {
String output = ourCtx.newXmlParser().encodeResourceToString(new Binary()); String output = ourCtx.newXmlParser().encodeResourceToString(new Binary());
@ -142,18 +142,16 @@ public class XmlParserDstu21Test {
ourCtx.newJsonParser().parseResource(encoded); ourCtx.newJsonParser().parseResource(encoded);
} }
@Test @Test
public void testEncodeDoesntIncludeUuidId() { public void testEncodeDoesntIncludeUuidId() {
Patient p = new Patient(); Patient p = new Patient();
p.setId(new IdDt("urn:uuid:42795ed8-041f-4ebf-b6f4-78ef6f64c2f2")); p.setId(new IdDt("urn:uuid:42795ed8-041f-4ebf-b6f4-78ef6f64c2f2"));
p.addIdentifier().setSystem("ACME"); p.addIdentifier().setSystem("ACME");
String actual = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(p); String actual = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(p);
assertThat(actual, not(containsString("78ef6f64c2f2"))); assertThat(actual, not(containsString("78ef6f64c2f2")));
} }
@Test @Test
public void testContainedResourceInExtensionUndeclared() { public void testContainedResourceInExtensionUndeclared() {
Patient p = new Patient(); Patient p = new Patient();
@ -341,11 +339,9 @@ public class XmlParserDstu21Test {
String enc = ourCtx.newXmlParser().encodeResourceToString(patient); String enc = ourCtx.newXmlParser().encodeResourceToString(patient);
assertThat(enc, containsString("<Patient xmlns=\"http://hl7.org/fhir\"><extension url=\"http://example.com/extensions#someext\"><valueDateTime value=\"2011-01-02T11:13:15\"/></extension>")); assertThat(enc, containsString("<Patient xmlns=\"http://hl7.org/fhir\"><extension url=\"http://example.com/extensions#someext\"><valueDateTime value=\"2011-01-02T11:13:15\"/></extension>"));
assertThat(enc, containsString("<modifierExtension url=\"http://example.com/extensions#modext\"><valueDate value=\"1995-01-02\"/></modifierExtension>")); assertThat(enc, containsString("<modifierExtension url=\"http://example.com/extensions#modext\"><valueDate value=\"1995-01-02\"/></modifierExtension>"));
assertThat(enc, containsString( assertThat(enc, containsString("<extension url=\"http://example.com#parent\"><extension url=\"http://example.com#child\"><valueString value=\"value1\"/></extension><extension url=\"http://example.com#child\"><valueString value=\"value2\"/></extension></extension>"));
"<extension url=\"http://example.com#parent\"><extension url=\"http://example.com#child\"><valueString value=\"value1\"/></extension><extension url=\"http://example.com#child\"><valueString value=\"value2\"/></extension></extension>"));
assertThat(enc, containsString("<given value=\"Joe\"><extension url=\"http://examples.com#givenext\"><valueString value=\"given\"/></extension></given>")); assertThat(enc, containsString("<given value=\"Joe\"><extension url=\"http://examples.com#givenext\"><valueString value=\"given\"/></extension></given>"));
assertThat(enc, containsString( assertThat(enc, containsString("<given value=\"Shmoe\"><extension url=\"http://examples.com#givenext_parent\"><extension url=\"http://examples.com#givenext_child\"><valueString value=\"CHILD\"/></extension></extension></given>"));
"<given value=\"Shmoe\"><extension url=\"http://examples.com#givenext_parent\"><extension url=\"http://examples.com#givenext_child\"><valueString value=\"CHILD\"/></extension></extension></given>"));
/* /*
* Now parse this back * Now parse this back
@ -524,8 +520,11 @@ public class XmlParserDstu21Test {
/** /**
* Test for #233 * Test for #233
*
* This was rolled back after a conversation with grahame
*/ */
@Test @Test
@Ignore
public void testEncodeAndParseProfiledDatatype() { public void testEncodeAndParseProfiledDatatype() {
MedicationOrder mo = new MedicationOrder(); MedicationOrder mo = new MedicationOrder();
mo.addDosageInstruction().getTiming().getRepeat().setBounds(new DurationDt().setCode("code")); mo.addDosageInstruction().getTiming().getRepeat().setBounds(new DurationDt().setCode("code"));
@ -541,7 +540,8 @@ public class XmlParserDstu21Test {
/** /**
* See #216 - Profiled datatypes should use their unprofiled parent type as the choice[x] name * See #216 - Profiled datatypes should use their unprofiled parent type as the choice[x] name
*/ */
@Test @Ignore @Test
@Ignore
public void testEncodeAndParseProfiledDatatypeChoice() throws Exception { public void testEncodeAndParseProfiledDatatypeChoice() throws Exception {
IParser xmlParser = ourCtx.newXmlParser(); IParser xmlParser = ourCtx.newXmlParser();
@ -751,10 +751,8 @@ public class XmlParserDstu21Test {
ourLog.info(encoded); ourLog.info(encoded);
// @formatter:on // @formatter:on
assertThat(encoded, assertThat(encoded, stringContainsInOrder("<MedicationOrder xmlns=\"http://hl7.org/fhir\">", "<contained>", "<Medication xmlns=\"http://hl7.org/fhir\">", "<id value=\"123\"/>", "<code>", "<coding>", "<system value=\"urn:sys\"/>", "<code value=\"code1\"/>", "</coding>", "</code>",
stringContainsInOrder("<MedicationOrder xmlns=\"http://hl7.org/fhir\">", "<contained>", "<Medication xmlns=\"http://hl7.org/fhir\">", "<id value=\"123\"/>", "<code>", "<coding>", "</Medication>", "</contained>", "<medicationReference>", "<reference value=\"#123\"/>", "<display value=\"MedRef\"/>", "</medicationReference>", "</MedicationOrder>"));
"<system value=\"urn:sys\"/>", "<code value=\"code1\"/>", "</coding>", "</code>", "</Medication>", "</contained>", "<medicationReference>", "<reference value=\"#123\"/>",
"<display value=\"MedRef\"/>", "</medicationReference>", "</MedicationOrder>"));
//@formatter:off //@formatter:off
} }
@ -786,10 +784,8 @@ public class XmlParserDstu21Test {
ourLog.info(encoded); ourLog.info(encoded);
//@formatter:on //@formatter:on
assertThat(encoded, assertThat(encoded, stringContainsInOrder("<MedicationOrder xmlns=\"http://hl7.org/fhir\">", "<contained>", "<Medication xmlns=\"http://hl7.org/fhir\">", "<id value=\"1\"/>", "<code>", "<coding>", "<system value=\"urn:sys\"/>", "<code value=\"code1\"/>", "</coding>", "</code>",
stringContainsInOrder("<MedicationOrder xmlns=\"http://hl7.org/fhir\">", "<contained>", "<Medication xmlns=\"http://hl7.org/fhir\">", "<id value=\"1\"/>", "<code>", "<coding>", "</Medication>", "</contained>", "<medicationReference>", "<reference value=\"#1\"/>", "<display value=\"MedRef\"/>", "</medicationReference>", "</MedicationOrder>"));
"<system value=\"urn:sys\"/>", "<code value=\"code1\"/>", "</coding>", "</code>", "</Medication>", "</contained>", "<medicationReference>", "<reference value=\"#1\"/>",
"<display value=\"MedRef\"/>", "</medicationReference>", "</MedicationOrder>"));
//@formatter:off //@formatter:off
} }
@ -824,10 +820,8 @@ public class XmlParserDstu21Test {
ourLog.info(encoded); ourLog.info(encoded);
//@formatter:on //@formatter:on
assertThat(encoded, assertThat(encoded, stringContainsInOrder("<MedicationOrder xmlns=\"http://hl7.org/fhir\">", "<contained>", "<Medication xmlns=\"http://hl7.org/fhir\">", "<id value=\"123\"/>", "<code>", "<coding>", "<system value=\"urn:sys\"/>", "<code value=\"code1\"/>", "</coding>", "</code>",
stringContainsInOrder("<MedicationOrder xmlns=\"http://hl7.org/fhir\">", "<contained>", "<Medication xmlns=\"http://hl7.org/fhir\">", "<id value=\"123\"/>", "<code>", "<coding>", "</Medication>", "</contained>", "<medicationReference>", "<reference value=\"#123\"/>", "<display value=\"MedRef\"/>", "</medicationReference>", "</MedicationOrder>"));
"<system value=\"urn:sys\"/>", "<code value=\"code1\"/>", "</coding>", "</code>", "</Medication>", "</contained>", "<medicationReference>", "<reference value=\"#123\"/>",
"<display value=\"MedRef\"/>", "</medicationReference>", "</MedicationOrder>"));
//@formatter:off //@formatter:off
} }
@ -1630,7 +1624,8 @@ public class XmlParserDstu21Test {
/** /**
* See #191 * See #191
*/ */
@Test @Ignore @Test
@Ignore
public void testParseBundleWithLinksOfUnknownRelation() throws Exception { public void testParseBundleWithLinksOfUnknownRelation() throws Exception {
String input = IOUtils.toString(XmlParserDstu21Test.class.getResourceAsStream("/bundle_orion.xml")); String input = IOUtils.toString(XmlParserDstu21Test.class.getResourceAsStream("/bundle_orion.xml"));
ca.uhn.fhir.model.dstu21.resource.Bundle parsed = ourCtx.newXmlParser().parseResource(ca.uhn.fhir.model.dstu21.resource.Bundle.class, input); ca.uhn.fhir.model.dstu21.resource.Bundle parsed = ourCtx.newXmlParser().parseResource(ca.uhn.fhir.model.dstu21.resource.Bundle.class, input);
@ -1664,7 +1659,8 @@ public class XmlParserDstu21Test {
/** /**
* see #144 and #146 * see #144 and #146
*/ */
@Test @Ignore @Test
@Ignore
public void testParseContained() { public void testParseContained() {
FhirContext c = FhirContext.forDstu2(); FhirContext c = FhirContext.forDstu2();

View File

@ -9,6 +9,7 @@ import java.util.Date;
import org.hamcrest.core.StringContains; import org.hamcrest.core.StringContains;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
@ -195,6 +196,7 @@ public class DefaultThymeleafNarrativeGeneratorTestDstu2 {
} }
@Test @Test
@Ignore
public void testGenerateMedicationPrescription() { public void testGenerateMedicationPrescription() {
MedicationOrder mp = new MedicationOrder(); MedicationOrder mp = new MedicationOrder();
mp.setId("12345"); mp.setId("12345");

View File

@ -32,6 +32,7 @@ import org.hamcrest.core.StringContains;
import org.hamcrest.text.StringContainsInOrder; import org.hamcrest.text.StringContainsInOrder;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
@ -68,6 +69,7 @@ import ca.uhn.fhir.model.dstu2.resource.MedicationOrder;
import ca.uhn.fhir.model.dstu2.resource.MedicationStatement; import ca.uhn.fhir.model.dstu2.resource.MedicationStatement;
import ca.uhn.fhir.model.dstu2.resource.Observation; import ca.uhn.fhir.model.dstu2.resource.Observation;
import ca.uhn.fhir.model.dstu2.resource.Organization; import ca.uhn.fhir.model.dstu2.resource.Organization;
import ca.uhn.fhir.model.dstu2.resource.Parameters;
import ca.uhn.fhir.model.dstu2.resource.Patient; import ca.uhn.fhir.model.dstu2.resource.Patient;
import ca.uhn.fhir.model.dstu2.valueset.AddressUseEnum; import ca.uhn.fhir.model.dstu2.valueset.AddressUseEnum;
import ca.uhn.fhir.model.dstu2.valueset.AdministrativeGenderEnum; import ca.uhn.fhir.model.dstu2.valueset.AdministrativeGenderEnum;
@ -84,6 +86,7 @@ import ca.uhn.fhir.model.primitive.DateDt;
import ca.uhn.fhir.model.primitive.DateTimeDt; import ca.uhn.fhir.model.primitive.DateTimeDt;
import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.primitive.InstantDt; import ca.uhn.fhir.model.primitive.InstantDt;
import ca.uhn.fhir.model.primitive.MarkdownDt;
import ca.uhn.fhir.model.primitive.StringDt; import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.parser.IParserErrorHandler.IParseLocation; import ca.uhn.fhir.parser.IParserErrorHandler.IParseLocation;
import ca.uhn.fhir.rest.client.IGenericClient; import ca.uhn.fhir.rest.client.IGenericClient;
@ -93,6 +96,46 @@ public class XmlParserDstu2Test {
private static final FhirContext ourCtx = FhirContext.forDstu2(); private static final FhirContext ourCtx = FhirContext.forDstu2();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(XmlParserDstu2Test.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(XmlParserDstu2Test.class);
@Test
public void testChoiceTypeWithProfiledType() {
//@formatter:off
String input = "<Patient xmlns=\"http://hl7.org/fhir\">\n" +
" <extension url=\"http://example.com\">\n" +
" <valueMarkdown value=\"THIS IS MARKDOWN\"/>\n" +
" </extension>\n" +
"</Patient>";
//@formatter:on
Patient parsed = ourCtx.newXmlParser().parseResource(Patient.class, input);
assertEquals(1, parsed.getUndeclaredExtensions().size());
ExtensionDt ext = parsed.getUndeclaredExtensions().get(0);
assertEquals("http://example.com", ext.getUrl());
assertEquals("THIS IS MARKDOWN", ((MarkdownDt)ext.getValue()).getValue());
String encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(parsed);
assertThat(encoded, containsString("<valueMarkdown value=\"THIS IS MARKDOWN\"/>"));
}
@Test
public void testChoiceTypeWithProfiledType2() {
Parameters par = new Parameters();
par.addParameter().setValue((StringDt)new StringDt().setValue("ST"));
par.addParameter().setValue((MarkdownDt)new MarkdownDt().setValue("MD"));
String str = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(par);
ourLog.info(str);
assertThat(str, stringContainsInOrder("<valueString value=\"ST\"/>", "<valueMarkdown value=\"MD\"/>"));
par = ourCtx.newXmlParser().parseResource(Parameters.class, str);
assertEquals(2, par.getParameter().size());
assertEquals(StringDt.class, par.getParameter().get(0).getValue().getClass());
assertEquals(MarkdownDt.class, par.getParameter().get(1).getValue().getClass());
}
@Test @Test
public void testBundleWithBinary() { public void testBundleWithBinary() {
//@formatter:off //@formatter:off
@ -522,7 +565,7 @@ public class XmlParserDstu2Test {
} }
/** /**
* Test for #233 * Test for #233 - This was reversed after a conversation with Grahame
*/ */
@Test @Test
public void testEncodeAndParseProfiledDatatype() { public void testEncodeAndParseProfiledDatatype() {
@ -530,7 +573,7 @@ public class XmlParserDstu2Test {
mo.addDosageInstruction().getTiming().getRepeat().setBounds(new DurationDt().setCode("code")); mo.addDosageInstruction().getTiming().getRepeat().setBounds(new DurationDt().setCode("code"));
String out = ourCtx.newXmlParser().encodeResourceToString(mo); String out = ourCtx.newXmlParser().encodeResourceToString(mo);
ourLog.info(out); ourLog.info(out);
assertThat(out, containsString("</boundsQuantity>")); assertThat(out, containsString("</boundsDuration>"));
mo = ourCtx.newXmlParser().parseResource(MedicationOrder.class, out); mo = ourCtx.newXmlParser().parseResource(MedicationOrder.class, out);
DurationDt duration = (DurationDt) mo.getDosageInstruction().get(0).getTiming().getRepeat().getBounds(); DurationDt duration = (DurationDt) mo.getDosageInstruction().get(0).getTiming().getRepeat().getBounds();
@ -539,8 +582,11 @@ public class XmlParserDstu2Test {
/** /**
* See #216 - Profiled datatypes should use their unprofiled parent type as the choice[x] name * See #216 - Profiled datatypes should use their unprofiled parent type as the choice[x] name
*
* Disabled because we reverted this change after a conversation with Grahame
*/ */
@Test @Test
@Ignore
public void testEncodeAndParseProfiledDatatypeChoice() throws Exception { public void testEncodeAndParseProfiledDatatypeChoice() throws Exception {
IParser xmlParser = ourCtx.newXmlParser(); IParser xmlParser = ourCtx.newXmlParser();
@ -550,7 +596,7 @@ public class XmlParserDstu2Test {
assertEquals("1", q.getValueElement().getValueAsString()); assertEquals("1", q.getValueElement().getValueAsString());
String output = xmlParser.encodeResourceToString(ms); String output = xmlParser.encodeResourceToString(ms);
assertThat(output, containsString("<quantityQuantity><value value=\"1\"/></quantityQuantity>")); assertThat(output, containsString("<quantitySimpleQuantity><value value=\"1\"/></quantitySimpleQuantity>"));
} }
@Test @Test

View File

@ -1143,7 +1143,7 @@ public class GenericClientDstu2Test {
assertEquals("http://example.com/fhir/Patient/1/$validate-code", capt.getAllValues().get(idx).getURI().toASCIIString()); assertEquals("http://example.com/fhir/Patient/1/$validate-code", capt.getAllValues().get(idx).getURI().toASCIIString());
ourLog.info(extractBody(capt, idx)); ourLog.info(extractBody(capt, idx));
assertEquals("<Parameters xmlns=\"http://hl7.org/fhir\"><parameter><name value=\"code\"/><valueString value=\"8495-4\"/></parameter><parameter><name value=\"system\"/><valueUri value=\"http://loinc.org\"/></parameter></Parameters>",extractBody(capt, idx)); assertEquals("<Parameters xmlns=\"http://hl7.org/fhir\"><parameter><name value=\"code\"/><valueCode value=\"8495-4\"/></parameter><parameter><name value=\"system\"/><valueUri value=\"http://loinc.org\"/></parameter></Parameters>",extractBody(capt, idx));
} }

View File

@ -182,7 +182,7 @@
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version> <version>2.19</version>
<configuration> <configuration>
<redirectTestOutputToFile>false</redirectTestOutputToFile> <redirectTestOutputToFile>true</redirectTestOutputToFile>
<runOrder>random</runOrder> <runOrder>random</runOrder>
<argLine>-Dfile.encoding=UTF-8</argLine> <argLine>-Dfile.encoding=UTF-8</argLine>
<reuseForks>false</reuseForks> <reuseForks>false</reuseForks>

View File

@ -26,7 +26,6 @@ import org.hamcrest.core.IsNot;
import org.hamcrest.core.StringContains; import org.hamcrest.core.StringContains;
import org.hamcrest.text.StringContainsInOrder; import org.hamcrest.text.StringContainsInOrder;
import org.hl7.fhir.instance.model.Address; import org.hl7.fhir.instance.model.Address;
import org.hl7.fhir.instance.model.Attachment;
import org.hl7.fhir.instance.model.Address.AddressUse; import org.hl7.fhir.instance.model.Address.AddressUse;
import org.hl7.fhir.instance.model.Address.AddressUseEnumFactory; import org.hl7.fhir.instance.model.Address.AddressUseEnumFactory;
import org.hl7.fhir.instance.model.Binary; import org.hl7.fhir.instance.model.Binary;
@ -49,7 +48,6 @@ import org.hl7.fhir.instance.model.Identifier.IdentifierUse;
import org.hl7.fhir.instance.model.InstantType; import org.hl7.fhir.instance.model.InstantType;
import org.hl7.fhir.instance.model.MedicationStatement; import org.hl7.fhir.instance.model.MedicationStatement;
import org.hl7.fhir.instance.model.Narrative.NarrativeStatus; import org.hl7.fhir.instance.model.Narrative.NarrativeStatus;
import org.hl7.fhir.instance.model.annotations.Child;
import org.hl7.fhir.instance.model.Observation; import org.hl7.fhir.instance.model.Observation;
import org.hl7.fhir.instance.model.Organization; import org.hl7.fhir.instance.model.Organization;
import org.hl7.fhir.instance.model.Patient; import org.hl7.fhir.instance.model.Patient;
@ -62,6 +60,7 @@ import org.hl7.fhir.instance.model.StringType;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IPrimitiveType; import org.hl7.fhir.instance.model.api.IPrimitiveType;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -91,8 +90,11 @@ public class XmlParserHl7OrgDstu2Test {
/** /**
* See #216 - Profiled datatypes should use their unprofiled parent type as the choice[x] name * See #216 - Profiled datatypes should use their unprofiled parent type as the choice[x] name
*
* Disabled after conversation with Grahame
*/ */
@Test @Test
@Ignore
public void testEncodeAndParseProfiledDatatypeChoice() throws Exception { public void testEncodeAndParseProfiledDatatypeChoice() throws Exception {
IParser xmlParser = ourCtx.newXmlParser(); IParser xmlParser = ourCtx.newXmlParser();

View File

@ -68,7 +68,9 @@ public class DatatypeGeneratorUsingSpreadsheet extends BaseStructureSpreadsheetP
for (ClassInfo classInfo : tlc) { for (ClassInfo classInfo : tlc) {
DatatypeDef def = Class.forName(classInfo.getName()).getAnnotation(DatatypeDef.class); DatatypeDef def = Class.forName(classInfo.getName()).getAnnotation(DatatypeDef.class);
if (def != null) { if (def != null) {
getNameToDatatypeClass().put(def.name(), classInfo.getName()); if (classInfo.getName().contains("Bound") == false) {
getNameToDatatypeClass().put(def.name(), classInfo.getName());
}
} }
} }
} catch (IOException e) { } catch (IOException e) {
@ -82,7 +84,9 @@ public class DatatypeGeneratorUsingSpreadsheet extends BaseStructureSpreadsheetP
for (ClassInfo classInfo : tlc) { for (ClassInfo classInfo : tlc) {
DatatypeDef def = Class.forName(classInfo.getName()).getAnnotation(DatatypeDef.class); DatatypeDef def = Class.forName(classInfo.getName()).getAnnotation(DatatypeDef.class);
if (def != null) { if (def != null) {
getNameToDatatypeClass().put(def.name(), classInfo.getName()); if (classInfo.getName().contains("Bound") == false) {
getNameToDatatypeClass().put(def.name(), classInfo.getName());
}
} }
} }
} catch (IOException e) { } catch (IOException e) {

30
pom.xml
View File

@ -240,7 +240,7 @@
<jetty_version>9.2.14.v20151106</jetty_version> <jetty_version>9.2.14.v20151106</jetty_version>
<!-- Note on Hibernate versions: Hibernate 4.3+ uses JPA 2.1, which is too new for a number of platforms including JBoss EAP 6.x and Glassfish 3.0. Upgrade this version with caution! Also note that if <!-- Note on Hibernate versions: Hibernate 4.3+ uses JPA 2.1, which is too new for a number of platforms including JBoss EAP 6.x and Glassfish 3.0. Upgrade this version with caution! Also note that if
you change this, you may get a failure in hibernate4-maven-plugin. See the note in hapi-fhir-jpaserver-base/pom.xml's configuration for that plugin... --> you change this, you may get a failure in hibernate4-maven-plugin. See the note in hapi-fhir-jpaserver-base/pom.xml's configuration for that plugin... -->
<hibernate_version>5.0.3.Final</hibernate_version> <hibernate_version>5.0.5.Final</hibernate_version>
<hibernate_validator_version>5.2.2.Final</hibernate_validator_version> <hibernate_validator_version>5.2.2.Final</hibernate_validator_version>
<maven_assembly_plugin_version>2.5.3</maven_assembly_plugin_version> <maven_assembly_plugin_version>2.5.3</maven_assembly_plugin_version>
<maven_failsafe_plugin_version>2.18.1</maven_failsafe_plugin_version> <maven_failsafe_plugin_version>2.18.1</maven_failsafe_plugin_version>
@ -251,7 +251,7 @@
<mitreid-connect-version>1.1.8</mitreid-connect-version> <mitreid-connect-version>1.1.8</mitreid-connect-version>
<phloc_schematron_version>2.7.1</phloc_schematron_version> <phloc_schematron_version>2.7.1</phloc_schematron_version>
<phloc_commons_version>4.3.6</phloc_commons_version> <phloc_commons_version>4.3.6</phloc_commons_version>
<spring_version>4.2.2.RELEASE</spring_version> <spring_version>4.2.3.RELEASE</spring_version>
<thymeleaf-version>2.1.4.RELEASE</thymeleaf-version> <thymeleaf-version>2.1.4.RELEASE</thymeleaf-version>
<ebay_cors_filter_version>1.0.1</ebay_cors_filter_version> <ebay_cors_filter_version>1.0.1</ebay_cors_filter_version>
<xmlunit_version>1.6</xmlunit_version> <xmlunit_version>1.6</xmlunit_version>
@ -277,7 +277,7 @@
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>18.0</version> <version>19.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.phloc</groupId> <groupId>com.phloc</groupId>
@ -392,12 +392,12 @@
<dependency> <dependency>
<groupId>org.apache.lucene</groupId> <groupId>org.apache.lucene</groupId>
<artifactId>lucene-highlighter</artifactId> <artifactId>lucene-highlighter</artifactId>
<version>5.3.0</version> <version>5.3.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.lucene</groupId> <groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-phonetic</artifactId> <artifactId>lucene-analyzers-phonetic</artifactId>
<version>5.3.0</version> <version>5.3.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven.doxia</groupId> <groupId>org.apache.maven.doxia</groupId>
@ -407,17 +407,17 @@
<dependency> <dependency>
<groupId>org.apache.maven.scm</groupId> <groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-api</artifactId> <artifactId>maven-scm-api</artifactId>
<version>1.9</version> <version>1.9.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven.scm</groupId> <groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-manager-plexus</artifactId> <artifactId>maven-scm-manager-plexus</artifactId>
<version>1.9</version> <version>1.9.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven.scm</groupId> <groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId> <artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.9</version> <version>1.9.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven.wagon</groupId> <groupId>org.apache.maven.wagon</groupId>
@ -552,7 +552,7 @@
<dependency> <dependency>
<groupId>org.hibernate</groupId> <groupId>org.hibernate</groupId>
<artifactId>hibernate-search-orm</artifactId> <artifactId>hibernate-search-orm</artifactId>
<version>5.5.0.Final</version> <version>5.5.1.Final</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.javassist</groupId> <groupId>org.javassist</groupId>
@ -562,17 +562,17 @@
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-android</artifactId> <artifactId>slf4j-android</artifactId>
<version>1.7.12</version> <version>1.7.13</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
<version>1.7.12</version> <version>1.7.13</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId> <artifactId>jcl-over-slf4j</artifactId>
<version>1.7.12</version> <version>1.7.13</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
@ -663,7 +663,7 @@
<plugin> <plugin>
<groupId>org.apache.felix</groupId> <groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId> <artifactId>maven-bundle-plugin</artifactId>
<version>3.0.0</version> <version>3.0.1</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
@ -931,12 +931,12 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId> <artifactId>maven-checkstyle-plugin</artifactId>
<version>2.15</version> <version>2.17</version>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.puppycrawl.tools</groupId> <groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId> <artifactId>checkstyle</artifactId>
<version>6.11.2</version> <version>6.13</version>
</dependency> </dependency>
</dependencies> </dependencies>
<configuration> <configuration>

View File

@ -7,6 +7,16 @@
</properties> </properties>
<body> <body>
<release version="1.4" date="TBD"> <release version="1.4" date="TBD">
<action type="add">
Bump the version of a few dependencies to the
latest versions (dependent HAPI modules listed in brackets):
<![CDATA[
<ul>
<li>Hibernate (JPA, Web Tester): 5.0.3 -&gt; 5.0.5</li>
<li>Springframework (JPA, Web Tester): 4.2.2 -&gt; 4.2.3</li>
</ul>
]]>
</action>
<action type="fix"> <action type="fix">
Remove a dependency on a Java 1.7 class Remove a dependency on a Java 1.7 class
(ReflectiveOperationException) in several spots in the (ReflectiveOperationException) in several spots in the
@ -55,6 +65,17 @@
remains committed to supporting JDK 6+ in the compiled library, but these remains committed to supporting JDK 6+ in the compiled library, but these
days it can only be built using JDK 8. Thanks to joelsch for the PR! days it can only be built using JDK 8. Thanks to joelsch for the PR!
</action> </action>
<action type="fix">
When serializing a value[x] field, if the value type was a profiled type (e.g. markdown is a
profile of string) HAPI 1.3 would use the base type in the element name, e.g.
valueString instead of valueMarkdown. After discussion with Grahame, this appears to
be incorrect behaviour so it has been fixed.
</action>
<action type="add" issue="240">
Support target parameter type in _include / _revinclude values, e.g.
_include=Patient:careProvider:Organization. Thanks to Joe Portner
for reporting!
<action>
</release> </release>
<release version="1.3" date="2015-11-14"> <release version="1.3" date="2015-11-14">
<action type="add"> <action type="add">