Merge branch 'master' of github.com:jamesagnew/hapi-fhir
This commit is contained in:
commit
7105890d2f
|
@ -7,6 +7,7 @@ import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
|||
import ca.uhn.fhir.jpa.search.ISearchCoordinatorSvc;
|
||||
import ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.api.SortSpec;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.test.utilities.UnregisterScheduledProcessor;
|
||||
|
@ -31,10 +32,8 @@ import org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator;
|
|||
import org.hl7.fhir.r4.model.*;
|
||||
import org.hl7.fhir.r4.model.Bundle.BundleType;
|
||||
import org.hl7.fhir.r4.model.Bundle.HTTPVerb;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.hl7.fhir.r4.model.codesystems.HttpVerb;
|
||||
import org.junit.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.util.AopTestUtils;
|
||||
|
@ -337,6 +336,45 @@ public class StressTestR4Test extends BaseResourceProviderR4Test {
|
|||
assertEquals(1202, resultsAndIncludes.size());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testUpdateListWithLargeNumberOfEntries() {
|
||||
int numPatients = 3000;
|
||||
|
||||
ListResource lr = new ListResource();
|
||||
lr.setId(IdType.newRandomUuid());
|
||||
|
||||
{
|
||||
Bundle bundle = new Bundle();
|
||||
for (int i = 0; i < numPatients; ++i) {
|
||||
Patient patient = new Patient();
|
||||
patient.setId(IdType.newRandomUuid());
|
||||
bundle.addEntry().setFullUrl(patient.getId()).setResource(patient).getRequest().setMethod(HTTPVerb.POST).setUrl("Patient");
|
||||
lr.addEntry().setItem(new Reference(patient.getId()));
|
||||
}
|
||||
bundle.addEntry().setFullUrl(lr.getId()).setResource(lr).getRequest().setMethod(HTTPVerb.POST).setUrl("List");
|
||||
|
||||
StopWatch sw = new StopWatch();
|
||||
ourLog.info("Saving list with {} entries", lr.getEntry().size());
|
||||
mySystemDao.transaction(null, bundle);
|
||||
ourLog.info("Saved {} resources in {}", bundle.getEntry().size(), sw);
|
||||
}
|
||||
|
||||
{
|
||||
Bundle bundle = new Bundle();
|
||||
|
||||
Patient newPatient = new Patient();
|
||||
newPatient.setId(IdType.newRandomUuid());
|
||||
bundle.addEntry().setFullUrl(newPatient.getId()).setResource(newPatient).getRequest().setMethod(HTTPVerb.POST).setUrl("Patient");
|
||||
lr.addEntry().setItem(new Reference(newPatient.getId()));
|
||||
bundle.addEntry().setFullUrl(lr.getId()).setResource(lr).getRequest().setMethod(HTTPVerb.PUT).setUrl(lr.getIdElement().toUnqualifiedVersionless().getValue());
|
||||
|
||||
StopWatch sw = new StopWatch();
|
||||
ourLog.info("Updating list with {} entries", lr.getEntry().size());
|
||||
mySystemDao.transaction(null, bundle);
|
||||
ourLog.info("Updated {} resources in {}", bundle.getEntry().size(), sw);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultithreadedSearch() throws Exception {
|
||||
|
|
|
@ -46,6 +46,11 @@
|
|||
<artifactId>hapi-fhir-structures-r4</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-r5</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
|
||||
|
|
|
@ -43,6 +43,8 @@ public class AnyListResource {
|
|||
return new AnyListResource(new org.hl7.fhir.dstu3.model.ListResource());
|
||||
case R4:
|
||||
return new AnyListResource(new org.hl7.fhir.r4.model.ListResource());
|
||||
case R5:
|
||||
return new AnyListResource(new org.hl7.fhir.r5.model.ListResource());
|
||||
default:
|
||||
throw new UnsupportedOperationException(version + " not supported");
|
||||
}
|
||||
|
@ -63,6 +65,11 @@ public class AnyListResource {
|
|||
myListResource = theListResourceR4;
|
||||
}
|
||||
|
||||
public AnyListResource(org.hl7.fhir.r5.model.ListResource theListResourceR5) {
|
||||
myFhirVersion = FhirVersionEnum.R5;
|
||||
myListResource = theListResourceR5;
|
||||
}
|
||||
|
||||
public static AnyListResource fromResource(IBaseResource theListResource) {
|
||||
if (theListResource instanceof ca.uhn.fhir.model.dstu2.resource.ListResource) {
|
||||
return new AnyListResource((ca.uhn.fhir.model.dstu2.resource.ListResource) theListResource);
|
||||
|
@ -70,6 +77,8 @@ public class AnyListResource {
|
|||
return new AnyListResource((org.hl7.fhir.dstu3.model.ListResource) theListResource);
|
||||
} else if (theListResource instanceof org.hl7.fhir.r4.model.ListResource) {
|
||||
return new AnyListResource((org.hl7.fhir.r4.model.ListResource) theListResource);
|
||||
} else if (theListResource instanceof org.hl7.fhir.r5.model.ListResource) {
|
||||
return new AnyListResource((org.hl7.fhir.r5.model.ListResource) theListResource);
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Cannot convert " + theListResource.getClass().getName() + " to AnyList");
|
||||
}
|
||||
|
@ -94,6 +103,11 @@ public class AnyListResource {
|
|||
return (org.hl7.fhir.r4.model.ListResource) get();
|
||||
}
|
||||
|
||||
public org.hl7.fhir.r5.model.ListResource getR5() {
|
||||
Validate.isTrue(myFhirVersion == FhirVersionEnum.R5);
|
||||
return (org.hl7.fhir.r5.model.ListResource) get();
|
||||
}
|
||||
|
||||
public FhirVersionEnum getFhirVersion() {
|
||||
return myFhirVersion;
|
||||
}
|
||||
|
@ -106,6 +120,9 @@ public class AnyListResource {
|
|||
case R4:
|
||||
getR4().getCode().addCoding().setSystem(theSystem).setCode(theCode);
|
||||
break;
|
||||
case R5:
|
||||
getR5().getCode().addCoding().setSystem(theSystem).setCode(theCode);
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
||||
}
|
||||
|
@ -119,6 +136,9 @@ public class AnyListResource {
|
|||
case R4:
|
||||
getR4().getIdentifier().add(new org.hl7.fhir.r4.model.Identifier().setSystem(theSystem).setValue(theValue));
|
||||
break;
|
||||
case R5:
|
||||
getR5().getIdentifier().add(new org.hl7.fhir.r5.model.Identifier().setSystem(theSystem).setValue(theValue));
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
||||
}
|
||||
|
@ -132,6 +152,9 @@ public class AnyListResource {
|
|||
case R4:
|
||||
getR4().addExtension().setUrl(theUrl).setValue(new org.hl7.fhir.r4.model.StringType(theValue));
|
||||
break;
|
||||
case R5:
|
||||
getR5().addExtension().setUrl(theUrl).setValue(new org.hl7.fhir.r5.model.StringType(theValue));
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
||||
}
|
||||
|
@ -143,6 +166,8 @@ public class AnyListResource {
|
|||
return getStringExtensionValueOrNullDstu3(theUrl);
|
||||
case R4:
|
||||
return getStringExtensionValueOrNullR4(theUrl);
|
||||
case R5:
|
||||
return getStringExtensionValueOrNullR5(theUrl);
|
||||
default:
|
||||
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
||||
}
|
||||
|
@ -166,6 +191,15 @@ public class AnyListResource {
|
|||
return targetType.getValue();
|
||||
}
|
||||
|
||||
private String getStringExtensionValueOrNullR5(String theUrl) {
|
||||
List<org.hl7.fhir.r5.model.Extension> targetTypes = getR5().getExtensionsByUrl(theUrl);
|
||||
if (targetTypes.size() < 1) {
|
||||
return null;
|
||||
}
|
||||
org.hl7.fhir.r5.model.StringType targetType = (org.hl7.fhir.r5.model.StringType) targetTypes.get(0).getValue();
|
||||
return targetType.getValue();
|
||||
}
|
||||
|
||||
public void addReference(IBaseReference theReference) {
|
||||
switch (myFhirVersion) {
|
||||
case DSTU3:
|
||||
|
@ -174,6 +208,9 @@ public class AnyListResource {
|
|||
case R4:
|
||||
getR4().addEntry().setItem((org.hl7.fhir.r4.model.Reference) theReference);
|
||||
break;
|
||||
case R5:
|
||||
getR5().addEntry().setItem((org.hl7.fhir.r5.model.Reference) theReference);
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
||||
}
|
||||
|
@ -187,6 +224,9 @@ public class AnyListResource {
|
|||
case R4:
|
||||
getR4().addEntry().setItem(new org.hl7.fhir.r4.model.Reference(theReferenceId));
|
||||
break;
|
||||
case R5:
|
||||
getR5().addEntry().setItem(new org.hl7.fhir.r5.model.Reference(theReferenceId));
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
||||
}
|
||||
|
@ -202,6 +242,10 @@ public class AnyListResource {
|
|||
return getR4().getEntry().stream()
|
||||
.map(entry -> entry.getItem().getReference())
|
||||
.map(reference -> new org.hl7.fhir.r4.model.IdType(reference).toUnqualifiedVersionless().getValue());
|
||||
case R5:
|
||||
return getR5().getEntry().stream()
|
||||
.map(entry -> entry.getItem().getReference())
|
||||
.map(reference -> new org.hl7.fhir.r5.model.IdType(reference).toUnqualifiedVersionless().getValue());
|
||||
default:
|
||||
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
||||
}
|
||||
|
@ -213,6 +257,8 @@ public class AnyListResource {
|
|||
return removeItemDstu3(theReferenceId);
|
||||
case R4:
|
||||
return removeItemR4(theReferenceId);
|
||||
case R5:
|
||||
return removeItemR5(theReferenceId);
|
||||
default:
|
||||
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
||||
}
|
||||
|
@ -250,6 +296,22 @@ public class AnyListResource {
|
|||
return removed;
|
||||
}
|
||||
|
||||
private boolean removeItemR5(String theReferenceId) {
|
||||
boolean removed = false;
|
||||
for (org.hl7.fhir.r5.model.ListResource.ListEntryComponent entry : getR5().getEntry()) {
|
||||
if (theReferenceId.equals(entry.getItem().getReference()) && !entry.getDeleted()) {
|
||||
entry.setDeleted(true);
|
||||
removed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (removed) {
|
||||
getR5().getEntry().removeIf(entry -> entry.getDeleted());
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
public TokenParam getCodeFirstRep() {
|
||||
switch (myFhirVersion) {
|
||||
case DSTU3:
|
||||
|
@ -258,17 +320,40 @@ public class AnyListResource {
|
|||
case R4:
|
||||
org.hl7.fhir.r4.model.Coding codingR4 = getR4().getCode().getCodingFirstRep();
|
||||
return new TokenParam(codingR4.getSystem(), codingR4.getCode());
|
||||
case R5:
|
||||
org.hl7.fhir.r5.model.Coding codingR5 = getR5().getCode().getCodingFirstRep();
|
||||
return new TokenParam(codingR5.getSystem(), codingR5.getCode());
|
||||
default:
|
||||
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
||||
}
|
||||
}
|
||||
|
||||
public TokenParam getIdentifierirstRep() {
|
||||
switch (myFhirVersion) {
|
||||
case DSTU3:
|
||||
org.hl7.fhir.dstu3.model.Identifier identDstu3 = getDstu3().getIdentifierFirstRep();
|
||||
return new TokenParam(identDstu3.getSystem(), identDstu3.getValue());
|
||||
case R4:
|
||||
org.hl7.fhir.r4.model.Identifier identR4 = getR4().getIdentifierFirstRep();
|
||||
return new TokenParam(identR4.getSystem(), identR4.getValue());
|
||||
case R5:
|
||||
org.hl7.fhir.r5.model.Identifier identR5 = getR5().getIdentifierFirstRep();
|
||||
return new TokenParam(identR5.getSystem(), identR5.getValue());
|
||||
default:
|
||||
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isEmpty() {
|
||||
switch (myFhirVersion) {
|
||||
case DSTU3:
|
||||
return getDstu3().getEntry().isEmpty();
|
||||
case R4:
|
||||
return getR4().getEntry().isEmpty();
|
||||
case R5:
|
||||
return getR5().getEntry().isEmpty();
|
||||
default:
|
||||
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package ca.uhn.fhir.jpa.model.any;
|
||||
|
||||
import org.hl7.fhir.r5.model.ListResource;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class AnyListResourceTest {
|
||||
@Test
|
||||
public void getCodeFirstRep() {
|
||||
AnyListResource listResource = AnyListResource.fromResource(new ListResource());
|
||||
listResource.addCode("foo", "bar");
|
||||
assertEquals("foo", listResource.getCodeFirstRep().getSystem());
|
||||
assertEquals("bar", listResource.getCodeFirstRep().getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getIdentifierFirstRep() {
|
||||
AnyListResource listResource = AnyListResource.fromResource(new ListResource());
|
||||
listResource.addIdentifier("foo", "bar");
|
||||
assertEquals("foo", listResource.getIdentifierirstRep().getSystem());
|
||||
assertEquals("bar", listResource.getIdentifierirstRep().getValue());
|
||||
}
|
||||
}
|
|
@ -114,6 +114,15 @@
|
|||
could be bypassed if a Content Type was not included.
|
||||
</action>
|
||||
</release>
|
||||
<release version="4.0.1" date="2019-09-03" description="Igloo (Point Release)">
|
||||
<action type="fix">
|
||||
This release contains no new or updated functionality, but addressed a dependency
|
||||
version that was left incorrectly requiring a SNAPSHOT maven build of the
|
||||
org.hl7.fhir.utilities module. Users who are successfully using HAPI FHIR 4.0.0
|
||||
do not need to upgrade, but any users who were blocked from upgrading due to
|
||||
snapshot dependency issues are advised to upgrade immediately.
|
||||
</action>
|
||||
</release>
|
||||
<release version="4.0.0" date="2019-08-14" description="Igloo">
|
||||
<action type="add">
|
||||
The version of a few dependencies have been bumped to the
|
||||
|
|
|
@ -67,6 +67,32 @@
|
|||
</section>
|
||||
|
||||
<section name="Announcements">
|
||||
<p>
|
||||
<b>September 3, 2019 - Community Survey and HAPI FHIR 4.0.1</b> -
|
||||
It is time for us to do another HAPI FHIR community survey. The survey is a not-quite-annual
|
||||
tradition that helps us to set priority for the coming year and get a pulse on how people
|
||||
are using HAPI FHIR.
|
||||
</p>
|
||||
<p>
|
||||
We would very much appreciate if everyone could take a few minutes to fill it out. The
|
||||
survey is short (2 pages / 5 mins) so it shouldn't be much of a burden.
|
||||
</p>
|
||||
<p>
|
||||
Access the survey here:
|
||||
<a href="http://bit.ly/33HO4cs">http://bit.ly/33HO4cs</a> (note that this URL was originally posted incorrectly. It is now fixed)
|
||||
</p>
|
||||
<p>
|
||||
In addition, a new HAPI FHIR release (4.0.1) has been uploaded to the
|
||||
Maven Central repos.
|
||||
This release contains no new or updated functionality, but addressed a dependency
|
||||
version that was left incorrectly requiring a SNAPSHOT maven build of the
|
||||
org.hl7.fhir.utilities module. Users who are successfully using HAPI FHIR 4.0.0
|
||||
do not need to upgrade, but any users who were blocked from upgrading due to
|
||||
snapshot dependency issues are advised to upgrade immediately.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
<b>August 14, 2019 - HAPI FHIR 4.0.0 (Igloo) Released</b> -
|
||||
The next release of HAPI has now been uploaded to the Maven repos and
|
||||
|
|
Loading…
Reference in New Issue