Add status to bundle entries

This commit is contained in:
James Agnew 2015-01-05 17:57:35 -05:00
parent b85b6b8993
commit c786b00950
10 changed files with 1404 additions and 78 deletions

View File

@ -42,61 +42,26 @@ public class BundleEntry extends BaseBundle {
//@formatter:on //@formatter:on
private TagList myCategories; private TagList myCategories;
private InstantDt myDeletedAt; private InstantDt myDeletedAt;
private CodeDt myDeletedResourceType;
private StringDt myDeletedResourceId;
private StringDt myDeletedResourceVersion;
public CodeDt getDeletedResourceType() {
if (myDeletedResourceType == null) {
myDeletedResourceType = new CodeDt();
}
return myDeletedResourceType;
}
public void setDeletedResourceType(CodeDt theDeletedResourceType) {
myDeletedResourceType = theDeletedResourceType;
}
public StringDt getDeletedResourceId() {
if (myDeletedResourceId == null) {
myDeletedResourceId = new StringDt();
}
return myDeletedResourceId;
}
public void setDeletedResourceId(StringDt theDeletedResourceId) {
myDeletedResourceId = theDeletedResourceId;
}
public StringDt getDeletedResourceVersion() {
if (myDeletedResourceVersion == null) {
myDeletedResourceVersion = new StringDt();
}
return myDeletedResourceVersion;
}
public void setDeletedResourceVersion(StringDt theDeletedResourceVersion) {
myDeletedResourceVersion = theDeletedResourceVersion;
}
private StringDt myDeletedByEmail; private StringDt myDeletedByEmail;
private StringDt myDeletedByName; private StringDt myDeletedByName;
private StringDt myDeletedComment; private StringDt myDeletedComment;
private StringDt myDeletedResourceId;
private CodeDt myDeletedResourceType;
private StringDt myDeletedResourceVersion;
private StringDt myLinkAlternate; private StringDt myLinkAlternate;
private StringDt myLinkBase;
private StringDt myLinkSearch; private StringDt myLinkSearch;
private StringDt myLinkSelf; private StringDt myLinkSelf;
private StringDt myLinkBase;
private InstantDt myPublished; private InstantDt myPublished;
private IResource myResource; private IResource myResource;
private DecimalDt myScore;
private BoundCodeDt<BundleEntryStatusEnum> myStatus;
private XhtmlDt mySummary; private XhtmlDt mySummary;
private StringDt myTitle; private StringDt myTitle;
private InstantDt myUpdated; private InstantDt myUpdated;
private BoundCodeDt<BundleEntryStatusEnum> myStatus;
private DecimalDt myScore;
/** /**
* @deprecated Tags wil become immutable in a future release of HAPI, so * @deprecated Tags wil become immutable in a future release of HAPI, so {@link #addCategory(String, String, String)} should be used instead
* {@link #addCategory(String, String, String)} should be used instead
*/ */
public Tag addCategory() { public Tag addCategory() {
Tag retVal = new Tag(); Tag retVal = new Tag();
@ -150,6 +115,27 @@ public class BundleEntry extends BaseBundle {
return myDeletedComment; return myDeletedComment;
} }
public StringDt getDeletedResourceId() {
if (myDeletedResourceId == null) {
myDeletedResourceId = new StringDt();
}
return myDeletedResourceId;
}
public CodeDt getDeletedResourceType() {
if (myDeletedResourceType == null) {
myDeletedResourceType = new CodeDt();
}
return myDeletedResourceType;
}
public StringDt getDeletedResourceVersion() {
if (myDeletedResourceVersion == null) {
myDeletedResourceVersion = new StringDt();
}
return myDeletedResourceVersion;
}
public StringDt getLinkAlternate() { public StringDt getLinkAlternate() {
if (myLinkAlternate == null) { if (myLinkAlternate == null) {
myLinkAlternate = new StringDt(); myLinkAlternate = new StringDt();
@ -189,6 +175,13 @@ public class BundleEntry extends BaseBundle {
return myResource; return myResource;
} }
public DecimalDt getScore() {
if (myScore == null) {
myScore = new DecimalDt();
}
return myScore;
}
public BoundCodeDt<BundleEntryStatusEnum> getStatus() { public BoundCodeDt<BundleEntryStatusEnum> getStatus() {
if (myStatus == null) { if (myStatus == null) {
myStatus = new BoundCodeDt<BundleEntryStatusEnum>(BundleEntryStatusEnum.VALUESET_BINDER); myStatus = new BoundCodeDt<BundleEntryStatusEnum>(BundleEntryStatusEnum.VALUESET_BINDER);
@ -211,9 +204,8 @@ public class BundleEntry extends BaseBundle {
} }
/** /**
* @deprecated <b>DSTU2 Note:</b> As of DSTU2, bundle entries no longer have an updated time (this bit of metadata has been moved * @deprecated <b>DSTU2 Note:</b> As of DSTU2, bundle entries no longer have an updated time (this bit of metadata has been moved to the resource &lt;meta/&gt; element so it is redundant here). In
* to the resource &lt;meta/&gt; element so it is redundant here). In preparation for DSTU2, it is recommended that you * preparation for DSTU2, it is recommended that you migrate code away from using this method and over to using resource metadata instead.
* migrate code away from using this method and over to using resource metadata instead.
*/ */
public InstantDt getUpdated() { public InstantDt getUpdated() {
if (myUpdated == null) { if (myUpdated == null) {
@ -221,7 +213,7 @@ public class BundleEntry extends BaseBundle {
} }
if (myUpdated.isEmpty() && myResource != null) { if (myUpdated.isEmpty() && myResource != null) {
InstantDt resourceUpdated = ResourceMetadataKeyEnum.UPDATED.get(myResource); InstantDt resourceUpdated = ResourceMetadataKeyEnum.UPDATED.get(myResource);
if (resourceUpdated!=null && !resourceUpdated.isEmpty()) { if (resourceUpdated != null && !resourceUpdated.isEmpty()) {
return resourceUpdated; return resourceUpdated;
} }
} }
@ -258,6 +250,18 @@ public class BundleEntry extends BaseBundle {
myDeletedComment = theDeletedComment; myDeletedComment = theDeletedComment;
} }
public void setDeletedResourceId(StringDt theDeletedResourceId) {
myDeletedResourceId = theDeletedResourceId;
}
public void setDeletedResourceType(CodeDt theDeletedResourceType) {
myDeletedResourceType = theDeletedResourceType;
}
public void setDeletedResourceVersion(StringDt theDeletedResourceVersion) {
myDeletedResourceVersion = theDeletedResourceVersion;
}
public void setLinkAlternate(StringDt theLinkAlternate) { public void setLinkAlternate(StringDt theLinkAlternate) {
myLinkAlternate = theLinkAlternate; myLinkAlternate = theLinkAlternate;
} }
@ -286,14 +290,17 @@ public class BundleEntry extends BaseBundle {
myResource = theResource; myResource = theResource;
} }
public void setScore(DecimalDt theScore) {
myScore = theScore;
}
public void setStatus(BoundCodeDt<BundleEntryStatusEnum> theStatus) { public void setStatus(BoundCodeDt<BundleEntryStatusEnum> theStatus) {
myStatus = theStatus; myStatus = theStatus;
} }
/** /**
* @deprecated <b>DSTU2 Note:</b> As of DSTU2, bundle entries no longer have an updated time (this bit of metadata has been moved * @deprecated <b>DSTU2 Note:</b> As of DSTU2, bundle entries no longer have an updated time (this bit of metadata has been moved to the resource &lt;meta/&gt; element so it is redundant here). In
* to the resource &lt;meta/&gt; element so it is redundant here). In preparation for DSTU2, it is recommended that you * preparation for DSTU2, it is recommended that you migrate code away from using this method and over to using resource metadata instead.
* migrate code away from using this method and over to using resource metadata instead.
*/ */
public void setUpdated(InstantDt theUpdated) { public void setUpdated(InstantDt theUpdated) {
Validate.notNull(theUpdated, "Updated may not be null"); Validate.notNull(theUpdated, "Updated may not be null");
@ -312,15 +319,4 @@ public class BundleEntry extends BaseBundle {
return b.toString(); return b.toString();
} }
public DecimalDt getScore() {
if (myScore == null) {
myScore = new DecimalDt();
}
return myScore;
}
public void setScore(DecimalDt theScore) {
myScore = theScore;
}
} }

View File

@ -21,6 +21,7 @@ package ca.uhn.fhir.rest.server;
*/ */
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.context.ProvidedResourceScanner; import ca.uhn.fhir.context.ProvidedResourceScanner;
import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.model.api.*; import ca.uhn.fhir.model.api.*;
@ -30,6 +31,7 @@ import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
import ca.uhn.fhir.model.dstu.resource.Binary; import ca.uhn.fhir.model.dstu.resource.Binary;
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.valueset.BundleEntryStatusEnum;
import ca.uhn.fhir.parser.IParser; import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.rest.annotation.Destroy; import ca.uhn.fhir.rest.annotation.Destroy;
import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.IdParam;
@ -1116,7 +1118,7 @@ public class RestfulServer extends HttpServlet {
bundle.getLinkBase().setValue(theServerBase); bundle.getLinkBase().setValue(theServerBase);
bundle.getLinkSelf().setValue(theCompleteUrl); bundle.getLinkSelf().setValue(theCompleteUrl);
List<IResource> addedResources = new ArrayList<IResource>(); List<IResource> includedResources = new ArrayList<IResource>();
Set<IdDt> addedResourceIds = new HashSet<IdDt>(); Set<IdDt> addedResourceIds = new HashSet<IdDt>();
for (IResource next : theResult) { for (IResource next : theResult) {
@ -1172,7 +1174,7 @@ public class RestfulServer extends HttpServlet {
references.addAll(newReferences); references.addAll(newReferences);
} }
addedResources.addAll(addedResourcesThisPass); includedResources.addAll(addedResourcesThisPass);
} while (references.isEmpty() == false); } while (references.isEmpty() == false);
@ -1183,8 +1185,11 @@ public class RestfulServer extends HttpServlet {
/* /*
* Actually add the resources to the bundle * Actually add the resources to the bundle
*/ */
for (IResource next : addedResources) { for (IResource next : includedResources) {
bundle.addResource(next, theContext, theServerBase); BundleEntry entry = bundle.addResource(next, theContext, theServerBase);
if (theContext.getVersion().getVersion().isNewerThan(FhirVersionEnum.DSTU1)) {
entry.getStatus().setValueAsEnum(BundleEntryStatusEnum.INCLUDE);
}
} }
bundle.getTotalResults().setValue(theTotalResults); bundle.getTotalResults().setValue(theTotalResults);

View File

@ -53,7 +53,18 @@ public class TestRestfulServer extends RestfulServer {
ETagSupportEnum etagSupport; ETagSupportEnum etagSupport;
String baseUrlProperty; String baseUrlProperty;
switch (fhirVersionParam.trim().toUpperCase()) { switch (fhirVersionParam.trim().toUpperCase()) {
case "DSTU": case "BASE": {
setFhirContext(FhirContext.forDstu1());
beans = myAppCtx.getBean("myResourceProvidersDstu1", List.class);
systemProvider = myAppCtx.getBean("mySystemProviderDstu1", JpaSystemProvider.class);
systemDao = myAppCtx.getBean("mySystemDaoDstu1", IFhirSystemDao.class);
etagSupport = ETagSupportEnum.DISABLED;
JpaConformanceProviderDstu1 confProvider = new JpaConformanceProviderDstu1(this, systemDao);
confProvider.setImplementationDescription(implDesc);
setServerConformanceProvider(confProvider);
baseUrlProperty = "fhir.baseurl";
break;
}
case "DSTU1": { case "DSTU1": {
setFhirContext(FhirContext.forDstu1()); setFhirContext(FhirContext.forDstu1());
beans = myAppCtx.getBean("myResourceProvidersDstu1", List.class); beans = myAppCtx.getBean("myResourceProvidersDstu1", List.class);
@ -66,7 +77,7 @@ public class TestRestfulServer extends RestfulServer {
baseUrlProperty = "fhir.baseurl.dstu1"; baseUrlProperty = "fhir.baseurl.dstu1";
break; break;
} }
case "DEV": { case "DSTU2": {
setFhirContext(FhirContext.forDev()); setFhirContext(FhirContext.forDev());
beans = myAppCtx.getBean("myResourceProvidersDev", List.class); beans = myAppCtx.getBean("myResourceProvidersDev", List.class);
systemProvider = myAppCtx.getBean("mySystemProviderDev", JpaSystemProvider.class); systemProvider = myAppCtx.getBean("mySystemProviderDev", JpaSystemProvider.class);
@ -82,32 +93,61 @@ public class TestRestfulServer extends RestfulServer {
throw new ServletException("Unknown FHIR version specified in init-param[FhirVersion]: " + fhirVersionParam); throw new ServletException("Unknown FHIR version specified in init-param[FhirVersion]: " + fhirVersionParam);
} }
/*
* On the DSTU2 endpoint, we want to enable ETag support
*/
setETagSupport(etagSupport); setETagSupport(etagSupport);
/*
* This server tries to dynamically generate narratives
*/
FhirContext ctx = getFhirContext(); FhirContext ctx = getFhirContext();
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator()); ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
/*
* The resource and system providers (which actually implement the various FHIR
* operations in this server) are all retrieved from the spring context above
* and are provided to the server here.
*/
for (IResourceProvider nextResourceProvider : beans) { for (IResourceProvider nextResourceProvider : beans) {
ourLog.info(" * Have resource provider for: {}", nextResourceProvider.getResourceType().getSimpleName()); ourLog.info(" * Have resource provider for: {}", nextResourceProvider.getResourceType().getSimpleName());
} }
setResourceProviders(beans); setResourceProviders(beans);
setPlainProviders(systemProvider); setPlainProviders(systemProvider);
/*
* This tells the server to use "incorrect" MIME types if it detects that the
* request is coming from a browser in the hopes that the browser won't just treat
* the content as a binary payload and try to download it (which is what generally
* happens if you load a FHIR URL in a browser)
*/
setUseBrowserFriendlyContentTypes(true); setUseBrowserFriendlyContentTypes(true);
/*
* The server's base URL (e.g. http://fhirtest.uhn.ca/baseDstu2) is
* pulled from a system property, which is helpful if you want to try
* hosting your own copy of this server.
*/
String baseUrl = System.getProperty(baseUrlProperty); String baseUrl = System.getProperty(baseUrlProperty);
if (StringUtils.isBlank(baseUrl)) { if (StringUtils.isBlank(baseUrl)) {
// Fall back to the old URL // Try to fall back in case the property isn't set
baseUrl = System.getProperty("fhir.baseurl"); baseUrl = System.getProperty("fhir.baseurl");
if (StringUtils.isBlank(baseUrl)) { if (StringUtils.isBlank(baseUrl)) {
throw new ServletException("Missing system property: " + baseUrlProperty); throw new ServletException("Missing system property: " + baseUrlProperty);
} }
} }
setServerAddressStrategy(new HardcodedServerAddressStrategy(baseUrl)); setServerAddressStrategy(new HardcodedServerAddressStrategy(baseUrl));
/*
* This is a simple paging strategy that keeps the last 10
* searches in memory
*/
setPagingProvider(new FifoMemoryPagingProvider(10)); setPagingProvider(new FifoMemoryPagingProvider(10));
/*
* Do some fancy logging to create a nice access log that has details
* about each incoming request.
*/
LoggingInterceptor loggingInterceptor = new LoggingInterceptor(); LoggingInterceptor loggingInterceptor = new LoggingInterceptor();
loggingInterceptor.setLoggerName("fhirtest.access"); loggingInterceptor.setLoggerName("fhirtest.access");
loggingInterceptor.setMessageFormat("Path[${servletPath}] Source[${requestHeader.x-forwarded-for}] Operation[${operationType} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}]"); loggingInterceptor.setMessageFormat("Path[${servletPath}] Source[${requestHeader.x-forwarded-for}] Operation[${operationType} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}]");

View File

@ -33,6 +33,20 @@
<load-on-startup>2</load-on-startup> <load-on-startup>2</load-on-startup>
</servlet> </servlet>
<servlet>
<servlet-name>fhirServletBase</servlet-name>
<servlet-class>ca.uhn.fhirtest.TestRestfulServer</servlet-class>
<init-param>
<param-name>ImplementationDescription</param-name>
<param-value>UHN Test Server (Base / DSTU1 Resources)</param-value>
</init-param>
<init-param>
<param-name>FhirVersion</param-name>
<param-value>BASE</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet> <servlet>
<servlet-name>fhirServletDstu1</servlet-name> <servlet-name>fhirServletDstu1</servlet-name>
<servlet-class>ca.uhn.fhirtest.TestRestfulServer</servlet-class> <servlet-class>ca.uhn.fhirtest.TestRestfulServer</servlet-class>
@ -48,21 +62,21 @@
</servlet> </servlet>
<servlet> <servlet>
<servlet-name>fhirServletDev</servlet-name> <servlet-name>fhirServletDstu2</servlet-name>
<servlet-class>ca.uhn.fhirtest.TestRestfulServer</servlet-class> <servlet-class>ca.uhn.fhirtest.TestRestfulServer</servlet-class>
<init-param> <init-param>
<param-name>ImplementationDescription</param-name> <param-name>ImplementationDescription</param-name>
<param-value>UHN Test Server (DEV Resources)</param-value> <param-value>UHN Test Server (DSTU2 Resources)</param-value>
</init-param> </init-param>
<init-param> <init-param>
<param-name>FhirVersion</param-name> <param-name>FhirVersion</param-name>
<param-value>DEV</param-value> <param-value>DSTU2</param-value>
</init-param> </init-param>
<load-on-startup>1</load-on-startup> <load-on-startup>1</load-on-startup>
</servlet> </servlet>
<servlet-mapping> <servlet-mapping>
<servlet-name>fhirServletDstu1</servlet-name> <servlet-name>fhirServletBase</servlet-name>
<url-pattern>/base/*</url-pattern> <url-pattern>/base/*</url-pattern>
</servlet-mapping> </servlet-mapping>
@ -72,12 +86,12 @@
</servlet-mapping> </servlet-mapping>
<servlet-mapping> <servlet-mapping>
<servlet-name>fhirServletDev</servlet-name> <servlet-name>fhirServletDstu2</servlet-name>
<url-pattern>/baseDstu2/*</url-pattern> <url-pattern>/baseDstu2/*</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet-mapping> <servlet-mapping>
<servlet-name>fhirServletDev</servlet-name> <servlet-name>fhirServletDstu2</servlet-name>
<url-pattern>/baseDev/*</url-pattern> <url-pattern>/baseDev/*</url-pattern>
</servlet-mapping> </servlet-mapping>

View File

@ -16,12 +16,12 @@
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name> <name>org.eclipse.wst.validation.validationbuilder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name> <name>org.eclipse.m2e.core.maven2Builder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>

View File

@ -50,6 +50,7 @@ public class XmlParserTest {
assertEquals(1, parsed.getEntries().size()); assertEquals(1, parsed.getEntries().size());
assertEquals("update", parsed.getEntries().get(0).getStatus().getValue()); assertEquals("update", parsed.getEntries().get(0).getStatus().getValue());
assertEquals("http://foo?search", parsed.getEntries().get(0).getLinkSearch().getValue());
MedicationPrescription p = (MedicationPrescription) parsed.getEntries().get(0).getResource(); MedicationPrescription p = (MedicationPrescription) parsed.getEntries().get(0).getResource();
assertEquals("Patient/example", p.getPatient().getReference().getValue()); assertEquals("Patient/example", p.getPatient().getReference().getValue());

View File

@ -0,0 +1,490 @@
package ca.uhn.fhir.rest.server;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.Include;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.Extension;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.dev.resource.DiagnosticReport;
import ca.uhn.fhir.model.dev.resource.Observation;
import ca.uhn.fhir.model.dev.resource.Organization;
import ca.uhn.fhir.model.dev.resource.Patient;
import ca.uhn.fhir.model.dev.resource.Practitioner;
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.model.valueset.BundleEntryStatusEnum;
import ca.uhn.fhir.rest.annotation.IncludeParam;
import ca.uhn.fhir.rest.annotation.RequiredParam;
import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.util.ElementUtil;
import ca.uhn.fhir.util.PortUtil;
/**
* Created by dsotnikov on 2/25/2014.
*/
public class IncludeTest {
private static CloseableHttpClient ourClient;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(IncludeTest.class);
private static int ourPort;
private static Server ourServer;
private static FhirContext ourCtx;
@Test
public void testNoIncludes() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello");
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);
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 testIIncludedResourcesNonContained() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=normalInclude&_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(3, 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(BundleEntryStatusEnum.INCLUDE, bundle.getEntries().get(2).getStatus().getValueAsEnum());
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
public void testIIncludedResourcesNonContainedInExtension() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=extInclude&_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(3, 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(BundleEntryStatusEnum.INCLUDE, bundle.getEntries().get(2).getStatus().getValueAsEnum());
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
public void testIIncludedResourcesNonContainedInExtensionJson() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=extInclude&_pretty=true&_format=json");
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.newJsonParser().parseBundle(responseContent);
ourLog.info(responseContent);
assertEquals(3, 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(BundleEntryStatusEnum.INCLUDE, bundle.getEntries().get(2).getStatus().getValueAsEnum());
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
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());
assertEquals(BundleEntryStatusEnum.INCLUDE, bundle.getEntries().get(2).getStatus().getValueAsEnum());
assertEquals(BundleEntryStatusEnum.INCLUDE, bundle.getEntries().get(3).getStatus().getValueAsEnum());
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
public void testTwoInclude() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello&_include=foo&_include=bar");
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(2, p.getName().size());
assertEquals("Hello", p.getId().getIdPart());
Set<String> values = new HashSet<String>();
values.add( p.getName().get(0).getFamilyFirstRep().getValue());
values.add( p.getName().get(1).getFamilyFirstRep().getValue());
assertThat(values, containsInAnyOrder("foo", "bar"));
}
@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());
}
@AfterClass
public static void afterClass() throws Exception {
ourServer.stop();
}
@BeforeClass
public static void beforeClass() throws Exception {
ourCtx = new FhirContext();
ourPort = PortUtil.findFreePort();
ourServer = new Server(ourPort);
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
RestfulServer servlet = new RestfulServer();
servlet.setFhirContext(ourCtx);
servlet.setResourceProviders(patientProvider, new DummyDiagnosticReportResourceProvider());
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
ourServer.setHandler(proxyHandler);
ourServer.start();
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
HttpClientBuilder builder = HttpClientBuilder.create();
builder.setConnectionManager(connectionManager);
ourClient = builder.build();
}
@ResourceDef(name="Patient")
public static class ExtPatient extends Patient
{
@Child(name="secondOrg")
@Extension(url="http://foo#secondOrg", definedLocally = false, isModifier = false)
private ResourceReferenceDt mySecondOrg;
@Override
public boolean isEmpty() {
return super.isEmpty() && ElementUtil.isEmpty(mySecondOrg);
}
public ResourceReferenceDt getSecondOrg() {
if (mySecondOrg==null) {
mySecondOrg= new ResourceReferenceDt();
}
return mySecondOrg;
}
public void setSecondOrg(ResourceReferenceDt theSecondOrg) {
mySecondOrg = theSecondOrg;
}
}
/**
* Created by dsotnikov on 2/25/2014.
*/
public static class DummyDiagnosticReportResourceProvider implements IResourceProvider {
@Override
public Class<? extends IResource> getResourceType() {
return DiagnosticReport.class;
}
@Search(queryName = "stitchedInclude")
public List<DiagnosticReport> stitchedInclude() {
Practitioner pr1 = new Practitioner();
pr1.setId("Practitioner/001");
pr1.getName().addFamily("Pract1");
Practitioner pr2 = new Practitioner();
pr2.setId("Practitioner/002");
pr2.getName().addFamily("Pract2");
Practitioner pr3 = new Practitioner();
pr3.setId("Practitioner/003");
pr3.getName().addFamily("Pract3");
Observation o1 = new Observation();
o1.getName().setText("Obs1");
o1.addPerformer().setResource(pr1);
Observation o2 = new Observation();
o2.getName().setText("Obs2");
o2.addPerformer().setResource(pr2);
Observation o3 = new Observation();
o3.getName().setText("Obs3");
o3.addPerformer().setResource(pr3);
DiagnosticReport rep = new DiagnosticReport();
rep.setId("DiagnosticReport/999");
rep.getName().setText("Rep");
rep.addResult().setResource(o1);
rep.addResult().setResource(o2);
rep.addResult().setResource(o3);
return Collections.singletonList(rep);
}
}
/**
* Created by dsotnikov on 2/25/2014.
*/
public static class DummyPatientResourceProvider implements IResourceProvider {
@Search(queryName = "normalInclude")
public List<Patient> normalInclude() {
Organization o1 = new Organization();
o1.getNameElement().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);
}
@Search(queryName = "extInclude")
public List<Patient> extInclude() {
Organization o1 = new Organization();
o1.getNameElement().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")
public List<ExtPatient> declaredExtInclude() {
Organization o1 = new Organization();
o1.getNameElement().setValue("o1");
o1.setId("o1");
Organization o2 = new Organization();
o2.getNameElement().setValue("o2");
o2.setId("o2");
o1.getPartOf().setResource(o2);
ExtPatient p1 = new ExtPatient();
p1.setId("p1");
p1.addIdentifier().setLabel("p1");
p1.getSecondOrg().setResource(o1);
ExtPatient p2 = new ExtPatient();
p2.setId("p2");
p2.addIdentifier().setLabel("p2");
p2.getSecondOrg().setResource(o1);
return Arrays.asList(p1, p2);
}
@Search(queryName = "containedInclude")
public List<Patient> containedInclude() {
Organization o1 = new Organization();
o1.getNameElement().setValue("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);
}
@Search
public List<Patient> findPatient(@RequiredParam(name = Patient.SP_NAME) StringDt theName, @IncludeParam(allow = { "foo", "bar" }) Set<Include> theIncludes) {
ArrayList<Patient> retVal = new ArrayList<Patient>();
Patient p = new Patient();
p.addIdentifier().setSystem("foo").setValue("bar");
p.setId(theName.getValue());
if (theIncludes != null) {
for (Include next : theIncludes) {
p.addName().addFamily().setValue(next.getValue());
}
}
retVal.add(p);
return retVal;
}
@Override
public Class<? extends IResource> getResourceType() {
return Patient.class;
}
}
public static void main(String[] args) {
Organization org = new Organization();
org.setId("Organization/65546");
org.getNameElement().setValue("Contained Test Organization");
Patient patient = new Patient();
patient.setId("Patient/1333");
patient.addIdentifier().setSystem("urn:mrns").setValue("253345");
patient.getManagingOrganization().setResource(patient);
System.out.println(new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(patient));
patient.getManagingOrganization().getReference();
}
}

View File

@ -17,6 +17,7 @@
</link> </link>
<entry> <entry>
<status value="update"/> <status value="update"/>
<search value="http://foo?search"/>
<resource> <resource>
<MedicationPrescription> <MedicationPrescription>
<id value="3123"/> <id value="3123"/>

View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bundle xmlns="http://hl7.org/fhir">
<id value="example"/>
<meta>
<versionId value="1"/>
<lastUpdated value="2014-08-18T01:43:30Z"/>
</meta>
<type value="transaction"/>
<base value="http://example.com/base"/>
<total value="3"/>
<link>
<relation value="next"/>
<url value="https://example.com/base/MedicationPrescription?patient=347&amp;searchId=ff15fd40-ff71-4b48-b366-09c706bed9d0&amp;page=2"/>
</link>
<link>
<relation value="self"/>
<url value="https://example.com/base/MedicationPrescription?patient=347"/>
</link>
<entry>
<status value="update"/>
<resource>
<MedicationPrescription>
<id value="3123"/>
<meta>
<versionId value="1"/>
<lastUpdated value="2014-08-16T05:31:17Z"/>
</meta>
<text>
<status value="generated"/>
<div xmlns="http://www.w3.org/1999/xhtml">
<p>Penicillin VK 5ml suspension to be administered by oral route</p>
<p>ONE 5ml spoonful to be taken THREE times a day</p>
<p>100ml bottle</p>
<p>to patient ref: a23</p>
<p>by doctor X</p>
</div>
</text>
<status value="active"/>
<patient>
<reference value="Patient/example"/>
</patient>
<prescriber>
<reference value="Practitioner/example"/>
</prescriber>
<medication>
<reference value="Medication/example"/>
</medication>
<dosageInstruction>
<scheduledTiming>
<repeat>
<frequency value="3"/>
<duration value="1"/>
<units value="d"/>
</repeat>
</scheduledTiming>
<route>
<coding>
<system value="http://snomed.info/sct"/>
<code value="394899003"/>
<display value="oral administration of treatment"/>
</coding>
</route>
<doseQuantity>
<value value="5"/>
<units value="ml"/>
<system value="http://unitsofmeasure.org"/>
<code value="ml"/>
</doseQuantity>
</dosageInstruction>
<dispense>
<quantity>
<value value="100"/>
<units value="ml"/>
<system value="http://unitsofmeasure.org"/>
<code value="ml"/>
</quantity>
</dispense>
</MedicationPrescription>
</resource>
</entry>
</Bundle>

694
pom.xml.orig Normal file
View File

@ -0,0 +1,694 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>9</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<packaging>pom</packaging>
<version>0.9-SNAPSHOT</version>
<name>HAPI-FHIR</name>
<url>http://hl7api.sourceforge.net/hapi-fhir/</url>
<organization>
<name>University Health Network</name>
<url>http://www.uhn.ca</url>
</organization>
<inceptionYear>2014</inceptionYear>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/jamesagnew/hapi-fhir/issues/</url>
</issueManagement>
<distributionManagement>
<site>
<id>git.server</id>
<url>scm:git:git@github.com:jamesagnew/hapi-fhir.git</url>
</site>
</distributionManagement>
<scm>
<connection>scm:git:git@github.com:jamesagnew/hapi-fhir.git</connection>
<url>scm:git:git@github.com:jamesagnew/hapi-fhir.git</url>
<developerConnection>scm:git:git@github.com:jamesagnew/hapi-fhir.git</developerConnection>
</scm>
<description>
</description>
<dependencies>
</dependencies>
<prerequisites>
<maven>3.0.1</maven>
</prerequisites>
<developers>
<developer>
<id>jamesagnew</id>
<name>James Agnew</name>
<organization>University Health Network</organization>
</developer>
<developer>
<name>Dmitri Sotnikov</name>
<organization>University Health Network</organization>
</developer>
<developer>
<name>Lisa Wong</name>
<organization>University Health Network</organization>
</developer>
<developer>
<name>Josh Mandel</name>
<organization>Boston Children's Hospital</organization>
</developer>
<developer>
<id>lmds</id>
<name>Laura MacDougall Sookraj</name>
<organization>University Health Network</organization>
</developer>
<developer>
<name>Neal Acharya</name>
<organization>University Health Network</organization>
</developer>
<developer>
<name>David Hay</name>
<organization>Orion Health</organization>
</developer>
<developer>
<id>suranga</id>
<name>Suranga Nath Kasthurirathne</name>
<organization>OpenMRS / Regenstrief Center for Biomedical Informatics</organization>
</developer>
<developer>
<id>dougmartin</id>
<name>Doug Martin</name>
<organization>Regenstrief Center for Biomedical Informatics</organization>
</developer>
<developer>
<id>akley</id>
<name>Alexander Kley</name>
</developer>
<developer>
<id>preston</id>
<name>Preston Lee</name>
<organization>Arizona State University</organization>
</developer>
<developer>
<id>jjathman</id>
<name>Joe Athman</name>
</developer>
<developer>
<id>petromykhailysyn</id>
<name>Petro Mykhailyshyn</name>
</developer>
<developer>
<id>tahurac</id>
<name>Tahura Chaudhry</name>
<organization>University Health Network</organization>
</developer>
<developer>
<id>b.debeaubien</id>
<name>Bill de Beaubien</name>
<organization>Systems Made Simple</organization>
</developer>
</developers>
<licenses>
<license>
<name>Apache Software License 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- For site-deploy -->
<siteMainDirectory>${user.home}/sites/hapi-fhir</siteMainDirectory>
<scmPubCheckoutDirectory>${user.home}/sites/scm/hapi-fhir</scmPubCheckoutDirectory>
<!-- Plugin Versions -->
<apache_httpclient_version>4.3.6</apache_httpclient_version>
<apache_httpcore_version>4.4</apache_httpcore_version>
<commons_io_version>2.4</commons_io_version>
<commons_lang_version>3.3.2</commons_lang_version>
<commons_codec_version>1.10</commons_codec_version>
<derby_version>10.11.1.1</derby_version>
<guava_version>18.0</guava_version>
<hamcrest_version>1.3</hamcrest_version>
<hibernate_version>4.3.7.Final<!-- 4.2.12.Final --></hibernate_version>
<hibernate_validator_version>5.1.0.Final</hibernate_validator_version>
<jetty_version>9.2.6.v20141205</jetty_version>
<jscience_version>4.3.1</jscience_version>
<junit_version>4.12</junit_version>
<logback_version>1.1.2</logback_version>
<maven_assembly_plugin_version>2.4.1</maven_assembly_plugin_version>
<maven_javadoc_plugin_version>2.10.1</maven_javadoc_plugin_version>
<maven_license_plugin_version>1.7</maven_license_plugin_version>
<maven_surefire_plugin_version>2.18.1</maven_surefire_plugin_version>
<maven_site_plugin_version>3.4</maven_site_plugin_version>
<maven_source_plugin_version>2.3</maven_source_plugin_version>
<mitreid-connect-version>1.1.8</mitreid-connect-version>
<mockito_version>1.10.17</mockito_version>
<phloc_schematron_version>2.7.1</phloc_schematron_version>
<phloc_commons_version>4.3.5</phloc_commons_version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<servlet_api_version>3.1.0</servlet_api_version>
<slf4j_version>1.7.9</slf4j_version>
<spring_version>4.1.3.RELEASE</spring_version>
<spring_security_version>3.2.4.RELEASE</spring_security_version>
<thymeleaf-version>2.1.4.RELEASE</thymeleaf-version>
<ebay_cors_filter_version>1.0.1</ebay_cors_filter_version>
<woodstox_version>4.4.0</woodstox_version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven_surefire_plugin_version}</version>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<runOrder>random</runOrder>
<<<<<<< HEAD
=======
<!--<argLine>-Dfile.encoding=ISO-8859-1</argLine> -->
>>>>>>> 8c96bf7d9ef6d6c590c3c7420c293b815935b336
<argLine>-Dfile.encoding=UTF-8</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>${maven_site_plugin_version}</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-module-markdown</artifactId>
<version>1.6</version>
</dependency>
</dependencies>
<configuration>
<skip>true</skip>
<skipDeploy>true</skipDeploy>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven_javadoc_plugin_version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven_source_plugin_version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>${maven_license_plugin_version}</version>
<configuration>
<verbose>true</verbose>
<addSvnKeyWords>false</addSvnKeyWords>
</configuration>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>${maven_site_plugin_version}</version>
<configuration>
<skip>false</skip>
<skipDeploy>true</skipDeploy>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-scm</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-manager-plexus</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-api</artifactId>
<version>1.9</version>
</dependency>
</dependencies>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
ca.uhn.hapi.fhir
</groupId>
<artifactId>
hapi-tinder-plugin
</artifactId>
<versionRange>
[0.8-SNAPSHOT,)
</versionRange>
<goals>
<goal>
generate-jparest-server
</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-antrun-plugin
</artifactId>
<versionRange>
[1.7,)
</versionRange>
<goals>
<goal>run</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<inherited>false</inherited>
<executions>
<execution>
<id>copySubProjects</id>
<phase>site</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<copy todir="target/site/apidocs">
<fileset dir="hapi-fhir-base/target/site/apidocs"/>
</copy>
<copy todir="target/site/apidocs-dstu">
<fileset dir="hapi-fhir-structures-dstu/target/site/apidocs"/>
</copy>
<copy todir="target/site/apidocs-dev">
<fileset dir="hapi-fhir-structures-dev/target/site/apidocs"/>
</copy>
</target>
</configuration>
</execution>
<execution>
<id>addSyntaxHighlighter</id>
<phase>site</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<echo>Adding Syntax Highlighter</echo>
<replace dir="target/site" summary="true">
<include name="*.html"></include>
<replacetoken><![CDATA[</body>]]></replacetoken>
<replacevalue><![CDATA[
<script type="text/javascript">
var elements = document.getElementsByClassName("source");
for (var i=0; i < elements.length; i++) {
var pres = elements[i].getElementsByTagName("pre");
for (var j = 0; j < pres.length; j++) {
var pre = pres[j];
if (pre.innerHTML.match(/\/\*/)) {
pre.className = 'brush: java';
} else if (pre.innerHTML.match(/^\/\//)) {
pre.className = 'brush: java';
} else if (pre.innerHTML.match(/^\{/)) {
pre.className = 'brush: jscript';
} else if (pre.innerHTML.match(/^\#/)) {
pre.className = 'brush: bash';
} else if (pre.innerHTML.match(/\&lt\;\//)) {
pre.className = 'brush: xml';
} else {
pre.className = 'brush: java';
}
}
}
SyntaxHighlighter.all();
</script>
</body>
]]></replacevalue>
</replace>
</target>
</configuration>
</execution>
<execution>
<id>addAnalytics</id>
<phase>post-site</phase>
<configuration>
<target>
<echo>Adding Google analytics in target/site for &lt;body&gt;</echo>
<replace dir="target/site" summary="true">
<include name="**/*.html"></include>
<replacefilter token="#build#" value="${label}" />
<replacefilter token="#version#" value="${project.version}" />
<replacetoken><![CDATA[</body>]]></replacetoken>
<replacevalue><![CDATA[
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-1395874-5', 'auto');
ga('require', 'displayfeatures');
ga('require', 'linkid', 'linkid.js');
ga('send', 'pageview');
</script>
</body >
]]></replacevalue>
</replace>
<echo>Adding Google analytics in target/site for &lt;BODY&gt;</echo>
<replace dir="target/site" summary="true">
<include name="**/*.html"></include>
<replacetoken><![CDATA[</BODY>]]></replacetoken>
<replacevalue><![CDATA[
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-1395874-5', 'auto');
ga('require', 'displayfeatures');
ga('require', 'linkid', 'linkid.js');
ga('send', 'pageview');
</script>
</BODY >
]]></replacevalue>
</replace>
<echo>Adding social plugins for HAPI</echo>
<replace dir="target/site/" summary="true">
<include name="**/*.html"></include>
<replacetoken><![CDATA[SOCIALPLUGINSHEREFHIR]]></replacetoken>
<replacevalue><![CDATA[
<table cellpadding="0" cellspacing="0" border="0"><tr>
<td><div class="g-plusone" data-annotation="inline" data-width="300" data-href="http://hl7api.sourceforge.net/"></div></td>
<td><div class="fb-like" data-href="http://hl7api.sourceforge.net/" data-send="false" data-layout="button_count" data-width="450" data-show-faces="true"></div></td>
</tr></table>
</p><p>
<!-- Place this tag after the last +1 button tag. -->
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
]]></replacevalue>
</replace>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.12</version>
<inherited>true</inherited>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java16</artifactId>
<version>1.01</version>
</signature>
</configuration>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<inherited>false</inherited>
<executions>
<execution>
<id>stage-for-scm-publish</id>
<phase>post-site</phase>
<goals>
<goal>stage</goal>
</goals>
<configuration>
<stagingDirectory>${siteMainDirectory}</stagingDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-publish-plugin</artifactId>
<version>1.1</version>
<inherited>false</inherited>
<configuration>
<checkoutDirectory>${scmPubCheckoutDirectory}</checkoutDirectory>
<content>\${siteMainDirectory}</content>
<tryUpdate>true</tryUpdate>
<scmBranch>gh-pages</scmBranch>
<pubScmUrl>scm:git:git@github.com:jamesagnew/hapi-fhir.git</pubScmUrl>
</configuration>
<executions>
<execution>
<id>scm-publish</id>
<phase>site-deploy</phase>
<goals>
<goal>publish-scm</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changes-plugin</artifactId>
<version>2.11</version>
<inherited>false</inherited>
<reportSets>
<reportSet>
<reports>
<report>changes-report</report>
</reports>
</reportSet>
</reportSets>
<configuration>
<feedType>atom_1.0</feedType>
<issueLinkTemplatePerSystem>
<default>https://github.com/jamesagnew/hapi-fhir/issues/%ISSUE%</default>
</issueLinkTemplatePerSystem>
<escapeHTML>false</escapeHTML>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>${maven_surefire_plugin_version}</version>
<configuration>
<aggregate>true</aggregate>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.7</version>
<inherited>false</inherited>
<reportSets>
<reportSet>
<reports>
<report>project-team</report>
<report>issue-tracking</report>
<report>license</report>
<report>scm</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<classFilesDirectory>./hapi-fhir-base/target/classes</classFilesDirectory>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>findbugs</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-linkcheck-plugin</artifactId>
<version>1.1</version> </plugin> -->
</plugins>
</reporting>
<profiles>
<profile>
<id>ROOT</id>
<modules>
</modules>
<build>
<plugins>
<!--
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven_assembly_plugin_version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<attach>false</attach>
<descriptors>
<descriptor>${project.basedir}/src/assembly/hapi-fhir-sample-projects.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
-->
</plugins>
</build>
</profile>
<profile>
<id>SIGN_ARTIFACTS</id>
<activation>
<property>
<name>gpg.passphrase</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>SITE</id>
<modules>
<module>hapi-fhir-base</module>
<module>hapi-fhir-structures-dstu</module>
<module>hapi-fhir-structures-dev</module>
<module>examples</module>
</modules>
</profile>
<profile>
<id>ALLMODULES</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<modules>
<module>hapi-deployable-pom</module>
<module>hapi-fhir-base</module>
<!--<module>hapi-fhir-oauth2</module>-->
<module>hapi-fhir-base/testmindeps</module>
<module>hapi-tinder-plugin</module>
<module>hapi-tinder-test</module>
<module>hapi-fhir-structures-dstu</module>
<module>hapi-fhir-structures-dev</module>
<module>hapi-fhir-jpaserver-base</module>
<module>hapi-fhir-jpaserver-test</module>
<module>restful-server-example</module>
<module>restful-server-example-test</module>
<module>hapi-fhir-testpage-overlay</module>
<module>hapi-fhir-jpaserver-uhnfhirtest</module>
<!-- <module>hapi-fhir-dist</module> -->
</modules>
</profile>
</profiles>
</project>