Compare commits
6 Commits
987b7e372f
...
abd8136bd3
Author | SHA1 | Date |
---|---|---|
jdar | abd8136bd3 | |
volodymyr-korzh | fb7571185a | |
Tadgh | 919e2d2405 | |
Thomas Papke | 3f6d1eb29b | |
Tadgh | 377e44b6ca | |
Martha Mitran | 20d3e6bb25 |
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
type: change
|
||||||
|
issue: 6261
|
||||||
|
title: "Upgrading to Jakarta had caused a problem with the version of java-simple-mail that was in use. This has been updated to be conformant
|
||||||
|
with the Jakarta Mail APIs. Thanks to Thomas Papke(@thopap) for the contribution!"
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
type: fix
|
||||||
|
issue: 6290
|
||||||
|
title: "Previously, a specific migration task was using the `TRIM()` function, which does not exist in MSSQL 2012. This was causing migrations targeting MSSQL 2012 to fail.
|
||||||
|
This has been corrected and replaced with usage of a combination of LTRIM() and RTRIM(). Thanks to Primož Delopst at Better for the contribution!"
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
type: fix
|
||||||
|
issue: 6305
|
||||||
|
title: "Previously, when having StorageSettings#getIndexMissingFields() == IndexEnabledEnum.DISABLED (default value)
|
||||||
|
and attempting to search with the missing qualifier against a resource type with multiple search parameters of type reference,
|
||||||
|
the returned results would be incorrect. This has been fixed."
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
type: fix
|
||||||
|
issue: 6317
|
||||||
|
title: "Previously, defining a unique combo Search Parameter with the DateTime component and submitting multiple
|
||||||
|
resources with the same dateTime element (e.g. Observation.effectiveDateTime) resulted in duplicate resource creation.
|
||||||
|
This has been fixed."
|
||||||
|
|
|
@ -1972,7 +1972,7 @@ public class SearchBuilder implements ISearchBuilder<JpaPid> {
|
||||||
* The loop allows us to create multiple combo index joins if there
|
* The loop allows us to create multiple combo index joins if there
|
||||||
* are multiple AND expressions for the related parameters.
|
* are multiple AND expressions for the related parameters.
|
||||||
*/
|
*/
|
||||||
while (validateParamValuesAreValidForComboParam(theRequest, theParams, comboParamNames)) {
|
while (validateParamValuesAreValidForComboParam(theRequest, theParams, comboParamNames, comboParam)) {
|
||||||
applyComboSearchParam(theQueryStack, theParams, theRequest, comboParamNames, comboParam);
|
applyComboSearchParam(theQueryStack, theParams, theRequest, comboParamNames, comboParam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2068,7 +2068,10 @@ public class SearchBuilder implements ISearchBuilder<JpaPid> {
|
||||||
* (e.g. <code>?date=gt2024-02-01</code>), etc.
|
* (e.g. <code>?date=gt2024-02-01</code>), etc.
|
||||||
*/
|
*/
|
||||||
private boolean validateParamValuesAreValidForComboParam(
|
private boolean validateParamValuesAreValidForComboParam(
|
||||||
RequestDetails theRequest, @Nonnull SearchParameterMap theParams, List<String> theComboParamNames) {
|
RequestDetails theRequest,
|
||||||
|
@Nonnull SearchParameterMap theParams,
|
||||||
|
List<String> theComboParamNames,
|
||||||
|
RuntimeSearchParam theComboParam) {
|
||||||
boolean paramValuesAreValidForCombo = true;
|
boolean paramValuesAreValidForCombo = true;
|
||||||
List<List<IQueryParameterType>> paramOrValues = new ArrayList<>(theComboParamNames.size());
|
List<List<IQueryParameterType>> paramOrValues = new ArrayList<>(theComboParamNames.size());
|
||||||
|
|
||||||
|
@ -2129,6 +2132,19 @@ public class SearchBuilder implements ISearchBuilder<JpaPid> {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Date params are not eligible for using composite unique index
|
||||||
|
// as index could contain date with different precision (e.g. DAY, SECOND)
|
||||||
|
if (nextParamDef.getParamType() == RestSearchParameterTypeEnum.DATE
|
||||||
|
&& theComboParam.getComboSearchParamType() == ComboSearchParamType.UNIQUE) {
|
||||||
|
ourLog.debug(
|
||||||
|
"Search with params {} is not a candidate for combo searching - "
|
||||||
|
+ "Unique combo search parameter '{}' has DATE type",
|
||||||
|
theComboParamNames,
|
||||||
|
nextParamName);
|
||||||
|
paramValuesAreValidForCombo = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CartesianProductUtil.calculateCartesianProductSize(paramOrValues) > 500) {
|
if (CartesianProductUtil.calculateCartesianProductSize(paramOrValues) > 500) {
|
||||||
|
|
|
@ -800,14 +800,19 @@ public class ResourceLinkPredicateBuilder extends BaseJoiningPredicateBuilder im
|
||||||
subquery.addCustomColumns(1);
|
subquery.addCustomColumns(1);
|
||||||
subquery.addFromTable(getTable());
|
subquery.addFromTable(getTable());
|
||||||
|
|
||||||
|
String resourceType = theParams.getResourceTablePredicateBuilder().getResourceType();
|
||||||
|
RuntimeSearchParam paramDefinition =
|
||||||
|
mySearchParamRegistry.getRuntimeSearchParam(resourceType, theParams.getParamName());
|
||||||
|
List<String> pathList = paramDefinition.getPathsSplitForResourceType(resourceType);
|
||||||
|
|
||||||
Condition subQueryCondition = ComboCondition.and(
|
Condition subQueryCondition = ComboCondition.and(
|
||||||
BinaryCondition.equalTo(
|
BinaryCondition.equalTo(
|
||||||
getResourceIdColumn(),
|
getResourceIdColumn(),
|
||||||
theParams.getResourceTablePredicateBuilder().getResourceIdColumn()),
|
theParams.getResourceTablePredicateBuilder().getResourceIdColumn()),
|
||||||
BinaryCondition.equalTo(
|
BinaryCondition.equalTo(getResourceTypeColumn(), generatePlaceholder(resourceType)),
|
||||||
getResourceTypeColumn(),
|
ComboCondition.or(pathList.stream()
|
||||||
generatePlaceholder(
|
.map(path -> BinaryCondition.equalTo(getColumnSourcePath(), generatePlaceholder(path)))
|
||||||
theParams.getResourceTablePredicateBuilder().getResourceType())));
|
.toArray(BinaryCondition[]::new)));
|
||||||
|
|
||||||
subquery.addCondition(subQueryCondition);
|
subquery.addCondition(subQueryCondition);
|
||||||
|
|
||||||
|
|
|
@ -566,7 +566,8 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
||||||
for (BaseResourceIndexedSearchParam nextParam : paramsListForCompositePart) {
|
for (BaseResourceIndexedSearchParam nextParam : paramsListForCompositePart) {
|
||||||
IQueryParameterType nextParamAsClientParam = nextParam.toQueryParameterType();
|
IQueryParameterType nextParamAsClientParam = nextParam.toQueryParameterType();
|
||||||
|
|
||||||
if (nextParamAsClientParam instanceof DateParam) {
|
if (theParam.getComboSearchParamType() == ComboSearchParamType.NON_UNIQUE
|
||||||
|
&& nextParamAsClientParam instanceof DateParam) {
|
||||||
DateParam date = (DateParam) nextParamAsClientParam;
|
DateParam date = (DateParam) nextParamAsClientParam;
|
||||||
if (date.getPrecision() != TemporalPrecisionEnum.DAY) {
|
if (date.getPrecision() != TemporalPrecisionEnum.DAY) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -70,6 +70,11 @@
|
||||||
<artifactId>jakarta.servlet-api</artifactId>
|
<artifactId>jakarta.servlet-api</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.mail</groupId>
|
||||||
|
<artifactId>jakarta.mail-api</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- test dependencies -->
|
<!-- test dependencies -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -28,8 +28,8 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import javax.mail.internet.InternetAddress;
|
import jakarta.mail.internet.InternetAddress;
|
||||||
import javax.mail.internet.MimeMessage;
|
import jakarta.mail.internet.MimeMessage;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
@ -17,8 +17,8 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.mail.internet.InternetAddress;
|
import jakarta.mail.internet.InternetAddress;
|
||||||
import javax.mail.internet.MimeMessage;
|
import jakarta.mail.internet.MimeMessage;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
|
@ -26,8 +26,8 @@ import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import javax.mail.internet.InternetAddress;
|
import jakarta.mail.internet.InternetAddress;
|
||||||
import javax.mail.internet.MimeMessage;
|
import jakarta.mail.internet.MimeMessage;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
@ -135,10 +135,10 @@ public abstract class BasePartitioningR4Test extends BaseJpaR4SystemTest {
|
||||||
addCreateDefaultPartition();
|
addCreateDefaultPartition();
|
||||||
addReadDefaultPartition(); // one for search param validation
|
addReadDefaultPartition(); // one for search param validation
|
||||||
SearchParameter sp = new SearchParameter();
|
SearchParameter sp = new SearchParameter();
|
||||||
sp.setId("SearchParameter/patient-birthdate");
|
sp.setId("SearchParameter/patient-gender");
|
||||||
sp.setType(Enumerations.SearchParamType.DATE);
|
sp.setType(Enumerations.SearchParamType.TOKEN);
|
||||||
sp.setCode("birthdate");
|
sp.setCode("gender");
|
||||||
sp.setExpression("Patient.birthDate");
|
sp.setExpression("Patient.gender");
|
||||||
sp.setStatus(Enumerations.PublicationStatus.ACTIVE);
|
sp.setStatus(Enumerations.PublicationStatus.ACTIVE);
|
||||||
sp.addBase("Patient");
|
sp.addBase("Patient");
|
||||||
mySearchParameterDao.update(sp, mySrd);
|
mySearchParameterDao.update(sp, mySrd);
|
||||||
|
@ -156,13 +156,13 @@ public abstract class BasePartitioningR4Test extends BaseJpaR4SystemTest {
|
||||||
|
|
||||||
addCreateDefaultPartition();
|
addCreateDefaultPartition();
|
||||||
sp = new SearchParameter();
|
sp = new SearchParameter();
|
||||||
sp.setId("SearchParameter/patient-birthdate-unique");
|
sp.setId("SearchParameter/patient-gender-family-unique");
|
||||||
sp.setType(Enumerations.SearchParamType.COMPOSITE);
|
sp.setType(Enumerations.SearchParamType.COMPOSITE);
|
||||||
sp.setStatus(Enumerations.PublicationStatus.ACTIVE);
|
sp.setStatus(Enumerations.PublicationStatus.ACTIVE);
|
||||||
sp.addBase("Patient");
|
sp.addBase("Patient");
|
||||||
sp.addComponent()
|
sp.addComponent()
|
||||||
.setExpression("Patient")
|
.setExpression("Patient")
|
||||||
.setDefinition("SearchParameter/patient-birthdate");
|
.setDefinition("SearchParameter/patient-gender");
|
||||||
sp.addComponent()
|
sp.addComponent()
|
||||||
.setExpression("Patient")
|
.setExpression("Patient")
|
||||||
.setDefinition("SearchParameter/patient-family");
|
.setDefinition("SearchParameter/patient-family");
|
||||||
|
|
|
@ -13,10 +13,10 @@ import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||||
import ca.uhn.fhir.jpa.searchparam.util.JpaParamUtil;
|
import ca.uhn.fhir.jpa.searchparam.util.JpaParamUtil;
|
||||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||||
import ca.uhn.fhir.rest.param.DateAndListParam;
|
|
||||||
import ca.uhn.fhir.rest.param.DateOrListParam;
|
|
||||||
import ca.uhn.fhir.rest.param.DateParam;
|
import ca.uhn.fhir.rest.param.DateParam;
|
||||||
import ca.uhn.fhir.rest.param.ReferenceParam;
|
import ca.uhn.fhir.rest.param.ReferenceParam;
|
||||||
|
import ca.uhn.fhir.rest.param.StringOrListParam;
|
||||||
|
import ca.uhn.fhir.rest.param.StringParam;
|
||||||
import ca.uhn.fhir.rest.param.TokenAndListParam;
|
import ca.uhn.fhir.rest.param.TokenAndListParam;
|
||||||
import ca.uhn.fhir.rest.param.TokenParam;
|
import ca.uhn.fhir.rest.param.TokenParam;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
|
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
|
||||||
|
@ -33,6 +33,7 @@ import org.hl7.fhir.r4.model.DateType;
|
||||||
import org.hl7.fhir.r4.model.Encounter;
|
import org.hl7.fhir.r4.model.Encounter;
|
||||||
import org.hl7.fhir.r4.model.Enumerations;
|
import org.hl7.fhir.r4.model.Enumerations;
|
||||||
import org.hl7.fhir.r4.model.Enumerations.PublicationStatus;
|
import org.hl7.fhir.r4.model.Enumerations.PublicationStatus;
|
||||||
|
import org.hl7.fhir.r4.model.HumanName;
|
||||||
import org.hl7.fhir.r4.model.IdType;
|
import org.hl7.fhir.r4.model.IdType;
|
||||||
import org.hl7.fhir.r4.model.Observation;
|
import org.hl7.fhir.r4.model.Observation;
|
||||||
import org.hl7.fhir.r4.model.Organization;
|
import org.hl7.fhir.r4.model.Organization;
|
||||||
|
@ -115,6 +116,46 @@ public class FhirResourceDaoR4ComboUniqueParamTest extends BaseComboParamsR4Test
|
||||||
myMessages.clear();
|
myMessages.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createUniqueGenderFamilyComboSp() {
|
||||||
|
SearchParameter sp = new SearchParameter();
|
||||||
|
sp.setId("SearchParameter/patient-gender");
|
||||||
|
sp.setType(Enumerations.SearchParamType.TOKEN);
|
||||||
|
sp.setCode("gender");
|
||||||
|
sp.setExpression("Patient.gender");
|
||||||
|
sp.setStatus(PublicationStatus.ACTIVE);
|
||||||
|
sp.addBase("Patient");
|
||||||
|
mySearchParameterDao.update(sp, mySrd);
|
||||||
|
|
||||||
|
sp = new SearchParameter();
|
||||||
|
sp.setId("SearchParameter/patient-family");
|
||||||
|
sp.setType(Enumerations.SearchParamType.STRING);
|
||||||
|
sp.setCode("family");
|
||||||
|
sp.setExpression("Patient.name.family");
|
||||||
|
sp.setStatus(Enumerations.PublicationStatus.ACTIVE);
|
||||||
|
sp.addBase("Patient");
|
||||||
|
mySearchParameterDao.update(sp, mySrd);
|
||||||
|
|
||||||
|
sp = new SearchParameter();
|
||||||
|
sp.setId("SearchParameter/patient-gender-family");
|
||||||
|
sp.setType(Enumerations.SearchParamType.COMPOSITE);
|
||||||
|
sp.setStatus(PublicationStatus.ACTIVE);
|
||||||
|
sp.addBase("Patient");
|
||||||
|
sp.addComponent()
|
||||||
|
.setExpression("Patient")
|
||||||
|
.setDefinition("SearchParameter/patient-gender");
|
||||||
|
sp.addComponent()
|
||||||
|
.setExpression("Patient")
|
||||||
|
.setDefinition("SearchParameter/patient-family");
|
||||||
|
sp.addExtension()
|
||||||
|
.setUrl(HapiExtensions.EXT_SP_UNIQUE)
|
||||||
|
.setValue(new BooleanType(true));
|
||||||
|
mySearchParameterDao.update(sp, mySrd);
|
||||||
|
|
||||||
|
mySearchParamRegistry.forceRefresh();
|
||||||
|
|
||||||
|
myMessages.clear();
|
||||||
|
}
|
||||||
|
|
||||||
private void createUniqueIndexCoverageBeneficiary() {
|
private void createUniqueIndexCoverageBeneficiary() {
|
||||||
SearchParameter sp = new SearchParameter();
|
SearchParameter sp = new SearchParameter();
|
||||||
sp.setId("SearchParameter/coverage-beneficiary");
|
sp.setId("SearchParameter/coverage-beneficiary");
|
||||||
|
@ -276,6 +317,45 @@ public class FhirResourceDaoR4ComboUniqueParamTest extends BaseComboParamsR4Test
|
||||||
mySearchParamRegistry.forceRefresh();
|
mySearchParamRegistry.forceRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createUniqueObservationDateCode() {
|
||||||
|
SearchParameter sp = new SearchParameter();
|
||||||
|
sp.setId("SearchParameter/obs-effective");
|
||||||
|
sp.setType(Enumerations.SearchParamType.DATE);
|
||||||
|
sp.setCode("date");
|
||||||
|
sp.setExpression("Observation.effective");
|
||||||
|
sp.setStatus(PublicationStatus.ACTIVE);
|
||||||
|
sp.addBase("Observation");
|
||||||
|
mySearchParameterDao.update(sp, mySrd);
|
||||||
|
|
||||||
|
sp = new SearchParameter();
|
||||||
|
sp.setId("SearchParameter/obs-code");
|
||||||
|
sp.setType(Enumerations.SearchParamType.TOKEN);
|
||||||
|
sp.setCode("code");
|
||||||
|
sp.setExpression("Observation.code");
|
||||||
|
sp.setStatus(PublicationStatus.ACTIVE);
|
||||||
|
sp.addBase("Observation");
|
||||||
|
mySearchParameterDao.update(sp, mySrd);
|
||||||
|
|
||||||
|
sp = new SearchParameter();
|
||||||
|
sp.setId("SearchParameter/observation-date-code");
|
||||||
|
sp.setType(Enumerations.SearchParamType.COMPOSITE);
|
||||||
|
sp.setStatus(PublicationStatus.ACTIVE);
|
||||||
|
sp.addBase("Observation");
|
||||||
|
sp.setExpression("Observation.code");
|
||||||
|
sp.addComponent()
|
||||||
|
.setExpression("Observation")
|
||||||
|
.setDefinition("SearchParameter/obs-effective");
|
||||||
|
sp.addComponent()
|
||||||
|
.setExpression("Observation")
|
||||||
|
.setDefinition("SearchParameter/obs-code");
|
||||||
|
sp.addExtension()
|
||||||
|
.setUrl(HapiExtensions.EXT_SP_UNIQUE)
|
||||||
|
.setValue(new BooleanType(true));
|
||||||
|
mySearchParameterDao.update(sp, mySrd);
|
||||||
|
|
||||||
|
mySearchParamRegistry.forceRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
private void createUniqueObservationSubjectDateCode() {
|
private void createUniqueObservationSubjectDateCode() {
|
||||||
SearchParameter sp = new SearchParameter();
|
SearchParameter sp = new SearchParameter();
|
||||||
sp.setId("SearchParameter/obs-subject");
|
sp.setId("SearchParameter/obs-subject");
|
||||||
|
@ -471,11 +551,11 @@ public class FhirResourceDaoR4ComboUniqueParamTest extends BaseComboParamsR4Test
|
||||||
public void testDoubleMatchingOnAnd_Search_TwoAndOrValues() {
|
public void testDoubleMatchingOnAnd_Search_TwoAndOrValues() {
|
||||||
myStorageSettings.setUniqueIndexesCheckedBeforeSave(false);
|
myStorageSettings.setUniqueIndexesCheckedBeforeSave(false);
|
||||||
|
|
||||||
createUniqueBirthdateAndGenderSps();
|
createUniqueGenderFamilyComboSp();
|
||||||
|
|
||||||
Patient pt1 = new Patient();
|
Patient pt1 = new Patient();
|
||||||
pt1.setGender(Enumerations.AdministrativeGender.MALE);
|
pt1.setGender(Enumerations.AdministrativeGender.MALE);
|
||||||
pt1.setBirthDateElement(new DateType("2011-01-01"));
|
pt1.getName().add(new HumanName().setFamily("Family1"));
|
||||||
String id1 = myPatientDao.create(pt1, mySrd).getId().toUnqualifiedVersionless().getValue();
|
String id1 = myPatientDao.create(pt1, mySrd).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
// Two OR values on the same resource - Currently composite SPs don't work for this
|
// Two OR values on the same resource - Currently composite SPs don't work for this
|
||||||
|
@ -484,17 +564,22 @@ public class FhirResourceDaoR4ComboUniqueParamTest extends BaseComboParamsR4Test
|
||||||
sp.setLoadSynchronous(true);
|
sp.setLoadSynchronous(true);
|
||||||
sp.add(Patient.SP_GENDER,
|
sp.add(Patient.SP_GENDER,
|
||||||
new TokenAndListParam()
|
new TokenAndListParam()
|
||||||
.addAnd(new TokenParam("http://hl7.org/fhir/administrative-gender","male"), new TokenParam( "http://hl7.org/fhir/administrative-gender","female"))
|
.addAnd(new TokenParam("http://hl7.org/fhir/administrative-gender","male"),
|
||||||
|
new TokenParam( "http://hl7.org/fhir/administrative-gender","female"))
|
||||||
);
|
);
|
||||||
sp.add(Patient.SP_BIRTHDATE,
|
sp.add(Patient.SP_FAMILY,
|
||||||
new DateAndListParam()
|
new StringOrListParam()
|
||||||
.addAnd(new DateParam("2011-01-01"), new DateParam( "2011-02-02"))
|
.addOr(new StringParam("Family1")).addOr(new StringParam("Family2"))
|
||||||
);
|
);
|
||||||
IBundleProvider outcome = myPatientDao.search(sp, mySrd);
|
IBundleProvider outcome = myPatientDao.search(sp, mySrd);
|
||||||
myCaptureQueriesListener.logFirstSelectQueryForCurrentThread();
|
myCaptureQueriesListener.logFirstSelectQueryForCurrentThread();
|
||||||
assertThat(toUnqualifiedVersionlessIdValues(outcome)).containsExactlyInAnyOrder(id1);
|
assertThat(toUnqualifiedVersionlessIdValues(outcome)).containsExactlyInAnyOrder(id1);
|
||||||
String unformattedSql = myCaptureQueriesListener.getSelectQueriesForCurrentThread().get(0).getSql(true, false);
|
String unformattedSql = myCaptureQueriesListener.getSelectQueriesForCurrentThread().get(0).getSql(true, false);
|
||||||
assertEquals("SELECT t0.RES_ID FROM HFJ_IDX_CMP_STRING_UNIQ t0 WHERE (t0.IDX_STRING IN ('Patient?birthdate=2011-01-01&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cfemale','Patient?birthdate=2011-01-01&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale','Patient?birthdate=2011-02-02&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cfemale','Patient?birthdate=2011-02-02&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale') )", unformattedSql);
|
assertEquals("SELECT t0.RES_ID FROM HFJ_IDX_CMP_STRING_UNIQ t0 WHERE (t0.IDX_STRING IN (" +
|
||||||
|
"'Patient?family=Family1&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cfemale'," +
|
||||||
|
"'Patient?family=Family1&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale'," +
|
||||||
|
"'Patient?family=Family2&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cfemale'," +
|
||||||
|
"'Patient?family=Family2&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale') )", unformattedSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1167,16 +1252,16 @@ public class FhirResourceDaoR4ComboUniqueParamTest extends BaseComboParamsR4Test
|
||||||
@Test
|
@Test
|
||||||
public void testOrQuery() {
|
public void testOrQuery() {
|
||||||
myStorageSettings.setAdvancedHSearchIndexing(false);
|
myStorageSettings.setAdvancedHSearchIndexing(false);
|
||||||
createUniqueBirthdateAndGenderSps();
|
createUniqueGenderFamilyComboSp();
|
||||||
|
|
||||||
Patient pt1 = new Patient();
|
Patient pt1 = new Patient();
|
||||||
pt1.setGender(Enumerations.AdministrativeGender.MALE);
|
pt1.setGender(Enumerations.AdministrativeGender.MALE);
|
||||||
pt1.setBirthDateElement(new DateType("2011-01-01"));
|
pt1.getName().add(new HumanName().setFamily("Family1"));
|
||||||
IIdType id1 = myPatientDao.create(pt1, mySrd).getId().toUnqualifiedVersionless();
|
IIdType id1 = myPatientDao.create(pt1, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
Patient pt2 = new Patient();
|
Patient pt2 = new Patient();
|
||||||
pt2.setGender(Enumerations.AdministrativeGender.MALE);
|
pt2.setGender(Enumerations.AdministrativeGender.MALE);
|
||||||
pt2.setBirthDateElement(new DateType("2011-01-02"));
|
pt2.getName().add(new HumanName().setFamily("Family2"));
|
||||||
IIdType id2 = myPatientDao.create(pt2, mySrd).getId().toUnqualifiedVersionless();
|
IIdType id2 = myPatientDao.create(pt2, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
myCaptureQueriesListener.clear();
|
myCaptureQueriesListener.clear();
|
||||||
|
@ -1184,16 +1269,21 @@ public class FhirResourceDaoR4ComboUniqueParamTest extends BaseComboParamsR4Test
|
||||||
SearchParameterMap params = new SearchParameterMap();
|
SearchParameterMap params = new SearchParameterMap();
|
||||||
params.setLoadSynchronousUpTo(100);
|
params.setLoadSynchronousUpTo(100);
|
||||||
params.add("gender", new TokenParam("http://hl7.org/fhir/administrative-gender", "male"));
|
params.add("gender", new TokenParam("http://hl7.org/fhir/administrative-gender", "male"));
|
||||||
params.add("birthdate", new DateOrListParam().addOr(new DateParam("2011-01-01")).addOr(new DateParam("2011-01-02")));
|
params.add("family", new StringOrListParam()
|
||||||
|
.addOr(new StringParam("Family1")).addOr(new StringParam("Family2")));
|
||||||
myCaptureQueriesListener.clear();
|
myCaptureQueriesListener.clear();
|
||||||
IBundleProvider results = myPatientDao.search(params, mySrd);
|
IBundleProvider results = myPatientDao.search(params, mySrd);
|
||||||
myCaptureQueriesListener.logFirstSelectQueryForCurrentThread();
|
myCaptureQueriesListener.logFirstSelectQueryForCurrentThread();
|
||||||
assertThat(toUnqualifiedVersionlessIdValues(results)).containsExactlyInAnyOrder(id1.getValue(), id2.getValue());
|
assertThat(toUnqualifiedVersionlessIdValues(results)).containsExactlyInAnyOrder(id1.getValue(), id2.getValue());
|
||||||
|
|
||||||
assertThat(myCaptureQueriesListener.getSelectQueries().get(0).getSql(true, false))
|
assertThat(myCaptureQueriesListener.getSelectQueries().get(0).getSql(true, false))
|
||||||
.contains("SELECT t0.RES_ID FROM HFJ_IDX_CMP_STRING_UNIQ t0 WHERE (t0.IDX_STRING IN ('Patient?birthdate=2011-01-01&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale','Patient?birthdate=2011-01-02&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale') )");
|
.contains("SELECT t0.RES_ID FROM HFJ_IDX_CMP_STRING_UNIQ t0 WHERE (t0.IDX_STRING IN " +
|
||||||
|
"('Patient?family=Family1&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale'," +
|
||||||
|
"'Patient?family=Family2&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale') )");
|
||||||
logCapturedMessages();
|
logCapturedMessages();
|
||||||
assertThat(myMessages.toString()).contains("Using UNIQUE index(es) for query for search: [Patient?birthdate=2011-01-01&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale, Patient?birthdate=2011-01-02&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale]");
|
assertThat(myMessages.toString()).contains("Using UNIQUE index(es) for query for search: " +
|
||||||
|
"[Patient?family=Family1&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale, " +
|
||||||
|
"Patient?family=Family2&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale]");
|
||||||
myMessages.clear();
|
myMessages.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1201,16 +1291,16 @@ public class FhirResourceDaoR4ComboUniqueParamTest extends BaseComboParamsR4Test
|
||||||
@Test
|
@Test
|
||||||
public void testSearchSynchronousUsingUniqueComposite() {
|
public void testSearchSynchronousUsingUniqueComposite() {
|
||||||
myStorageSettings.setAdvancedHSearchIndexing(false);
|
myStorageSettings.setAdvancedHSearchIndexing(false);
|
||||||
createUniqueBirthdateAndGenderSps();
|
createUniqueGenderFamilyComboSp();
|
||||||
|
|
||||||
Patient pt1 = new Patient();
|
Patient pt1 = new Patient();
|
||||||
pt1.setGender(Enumerations.AdministrativeGender.MALE);
|
pt1.setGender(Enumerations.AdministrativeGender.MALE);
|
||||||
pt1.setBirthDateElement(new DateType("2011-01-01"));
|
pt1.getName().add(new HumanName().setFamily("Family1"));
|
||||||
IIdType id1 = myPatientDao.create(pt1, mySrd).getId().toUnqualifiedVersionless();
|
IIdType id1 = myPatientDao.create(pt1, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
Patient pt2 = new Patient();
|
Patient pt2 = new Patient();
|
||||||
pt2.setGender(Enumerations.AdministrativeGender.MALE);
|
pt2.setGender(Enumerations.AdministrativeGender.MALE);
|
||||||
pt2.setBirthDateElement(new DateType("2011-01-02"));
|
pt2.getName().add(new HumanName().setFamily("Family2"));
|
||||||
myPatientDao.create(pt2, mySrd).getId().toUnqualifiedVersionless();
|
myPatientDao.create(pt2, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
myCaptureQueriesListener.clear();
|
myCaptureQueriesListener.clear();
|
||||||
|
@ -1218,13 +1308,14 @@ public class FhirResourceDaoR4ComboUniqueParamTest extends BaseComboParamsR4Test
|
||||||
SearchParameterMap params = new SearchParameterMap();
|
SearchParameterMap params = new SearchParameterMap();
|
||||||
params.setLoadSynchronousUpTo(100);
|
params.setLoadSynchronousUpTo(100);
|
||||||
params.add("gender", new TokenParam("http://hl7.org/fhir/administrative-gender", "male"));
|
params.add("gender", new TokenParam("http://hl7.org/fhir/administrative-gender", "male"));
|
||||||
params.add("birthdate", new DateParam("2011-01-01"));
|
params.add("family", new StringParam("Family1"));
|
||||||
IBundleProvider results = myPatientDao.search(params, mySrd);
|
IBundleProvider results = myPatientDao.search(params, mySrd);
|
||||||
myCaptureQueriesListener.logFirstSelectQueryForCurrentThread();
|
myCaptureQueriesListener.logFirstSelectQueryForCurrentThread();
|
||||||
assertThat(toUnqualifiedVersionlessIdValues(results)).containsExactlyInAnyOrder(id1.getValue());
|
assertThat(toUnqualifiedVersionlessIdValues(results)).containsExactlyInAnyOrder(id1.getValue());
|
||||||
|
|
||||||
logCapturedMessages();
|
logCapturedMessages();
|
||||||
assertThat(myMessages.toString()).contains("Using UNIQUE index(es) for query for search: Patient?birthdate=2011-01-01&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale");
|
assertThat(myMessages.toString()).contains("Using UNIQUE index(es) for query for search: " +
|
||||||
|
"Patient?family=Family1&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale");
|
||||||
myMessages.clear();
|
myMessages.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1232,33 +1323,34 @@ public class FhirResourceDaoR4ComboUniqueParamTest extends BaseComboParamsR4Test
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSearchUsingUniqueComposite() {
|
public void testSearchUsingUniqueComposite() {
|
||||||
createUniqueBirthdateAndGenderSps();
|
createUniqueGenderFamilyComboSp();
|
||||||
|
|
||||||
Patient pt1 = new Patient();
|
Patient pt1 = new Patient();
|
||||||
pt1.setGender(Enumerations.AdministrativeGender.MALE);
|
pt1.setGender(Enumerations.AdministrativeGender.MALE);
|
||||||
pt1.setBirthDateElement(new DateType("2011-01-01"));
|
pt1.getName().add(new HumanName().setFamily("Family1"));
|
||||||
String id1 = myPatientDao.create(pt1, mySrd).getId().toUnqualifiedVersionless().getValue();
|
String id1 = myPatientDao.create(pt1, mySrd).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
Patient pt2 = new Patient();
|
Patient pt2 = new Patient();
|
||||||
pt2.setGender(Enumerations.AdministrativeGender.MALE);
|
pt2.setGender(Enumerations.AdministrativeGender.MALE);
|
||||||
pt2.setBirthDateElement(new DateType("2011-01-02"));
|
pt2.getName().add(new HumanName().setFamily("Family2"));
|
||||||
myPatientDao.create(pt2, mySrd).getId().toUnqualifiedVersionless();
|
myPatientDao.create(pt2, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
myMessages.clear();
|
myMessages.clear();
|
||||||
SearchParameterMap params = new SearchParameterMap();
|
SearchParameterMap params = new SearchParameterMap();
|
||||||
params.add("gender", new TokenParam("http://hl7.org/fhir/administrative-gender", "male"));
|
params.add("gender", new TokenParam("http://hl7.org/fhir/administrative-gender", "male"));
|
||||||
params.add("birthdate", new DateParam("2011-01-01"));
|
params.add("family", new StringParam("Family1"));
|
||||||
IBundleProvider results = myPatientDao.search(params, mySrd);
|
IBundleProvider results = myPatientDao.search(params, mySrd);
|
||||||
String searchId = results.getUuid();
|
String searchId = results.getUuid();
|
||||||
assertThat(toUnqualifiedVersionlessIdValues(results)).containsExactlyInAnyOrder(id1);
|
assertThat(toUnqualifiedVersionlessIdValues(results)).containsExactlyInAnyOrder(id1);
|
||||||
logCapturedMessages();
|
logCapturedMessages();
|
||||||
assertThat(myMessages.toString()).contains("Using UNIQUE index(es) for query for search: Patient?birthdate=2011-01-01&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale");
|
assertThat(myMessages.toString()).contains("Using UNIQUE index(es) for query for search: " +
|
||||||
|
"Patient?family=Family1&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale");
|
||||||
myMessages.clear();
|
myMessages.clear();
|
||||||
|
|
||||||
// Other order
|
// Other order
|
||||||
myMessages.clear();
|
myMessages.clear();
|
||||||
params = new SearchParameterMap();
|
params = new SearchParameterMap();
|
||||||
params.add("birthdate", new DateParam("2011-01-01"));
|
params.add("family", new StringParam("Family1"));
|
||||||
params.add("gender", new TokenParam("http://hl7.org/fhir/administrative-gender", "male"));
|
params.add("gender", new TokenParam("http://hl7.org/fhir/administrative-gender", "male"));
|
||||||
results = myPatientDao.search(params, mySrd);
|
results = myPatientDao.search(params, mySrd);
|
||||||
assertEquals(searchId, results.getUuid());
|
assertEquals(searchId, results.getUuid());
|
||||||
|
@ -1272,16 +1364,17 @@ public class FhirResourceDaoR4ComboUniqueParamTest extends BaseComboParamsR4Test
|
||||||
myMessages.clear();
|
myMessages.clear();
|
||||||
params = new SearchParameterMap();
|
params = new SearchParameterMap();
|
||||||
params.add("gender", new TokenParam("http://hl7.org/fhir/administrative-gender", "male"));
|
params.add("gender", new TokenParam("http://hl7.org/fhir/administrative-gender", "male"));
|
||||||
params.add("birthdate", new DateParam("2011-01-03"));
|
params.add("family", new StringParam("Family3"));
|
||||||
results = myPatientDao.search(params, mySrd);
|
results = myPatientDao.search(params, mySrd);
|
||||||
assertThat(toUnqualifiedVersionlessIdValues(results)).isEmpty();
|
assertThat(toUnqualifiedVersionlessIdValues(results)).isEmpty();
|
||||||
logCapturedMessages();
|
logCapturedMessages();
|
||||||
assertThat(myMessages.toString()).contains("Using UNIQUE index(es) for query for search: Patient?birthdate=2011-01-03&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale");
|
assertThat(myMessages.toString()).contains("Using UNIQUE index(es) for query for search: " +
|
||||||
|
"Patient?family=Family3&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale");
|
||||||
myMessages.clear();
|
myMessages.clear();
|
||||||
|
|
||||||
myMessages.clear();
|
myMessages.clear();
|
||||||
params = new SearchParameterMap();
|
params = new SearchParameterMap();
|
||||||
params.add("birthdate", new DateParam("2011-01-03"));
|
params.add("family", new StringParam("Family3"));
|
||||||
results = myPatientDao.search(params, mySrd);
|
results = myPatientDao.search(params, mySrd);
|
||||||
assertThat(toUnqualifiedVersionlessIdValues(results)).isEmpty();
|
assertThat(toUnqualifiedVersionlessIdValues(results)).isEmpty();
|
||||||
// STANDARD QUERY
|
// STANDARD QUERY
|
||||||
|
@ -1666,7 +1759,7 @@ public class FhirResourceDaoR4ComboUniqueParamTest extends BaseComboParamsR4Test
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDuplicateUniqueValuesAreRejected() {
|
public void testDuplicateUniqueValuesWithDateAreRejected() {
|
||||||
createUniqueBirthdateAndGenderSps();
|
createUniqueBirthdateAndGenderSps();
|
||||||
|
|
||||||
Patient pt1 = new Patient();
|
Patient pt1 = new Patient();
|
||||||
|
@ -1699,13 +1792,75 @@ public class FhirResourceDaoR4ComboUniqueParamTest extends BaseComboParamsR4Test
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReplaceOneWithAnother() {
|
public void testDuplicateUniqueValuesWithDateTimeAreRejected() {
|
||||||
myStorageSettings.setAdvancedHSearchIndexing(false);
|
createUniqueObservationDateCode();
|
||||||
|
|
||||||
|
Observation obs = new Observation();
|
||||||
|
obs.getCode().addCoding().setSystem("foo").setCode("bar");
|
||||||
|
obs.setEffective(new DateTimeType("2017-10-10T00:00:00"));
|
||||||
|
myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
|
try {
|
||||||
|
myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
fail();
|
||||||
|
} catch (ResourceVersionConflictException e) {
|
||||||
|
assertThat(e.getMessage())
|
||||||
|
.contains("new unique index created by SearchParameter/observation-date-code");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUniqueComboSearchWithDateNotUsingUniqueIndex() {
|
||||||
createUniqueBirthdateAndGenderSps();
|
createUniqueBirthdateAndGenderSps();
|
||||||
|
|
||||||
Patient pt1 = new Patient();
|
Patient pt1 = new Patient();
|
||||||
pt1.setGender(Enumerations.AdministrativeGender.MALE);
|
pt1.setGender(Enumerations.AdministrativeGender.MALE);
|
||||||
pt1.setBirthDateElement(new DateType("2011-01-01"));
|
pt1.setBirthDateElement(new DateType("2011-01-01"));
|
||||||
|
String pId = myPatientDao.create(pt1, mySrd).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
|
myCaptureQueriesListener.clear();
|
||||||
|
SearchParameterMap params = new SearchParameterMap();
|
||||||
|
params.setLoadSynchronousUpTo(100);
|
||||||
|
params.add("gender", new TokenParam("http://hl7.org/fhir/administrative-gender", "male"));
|
||||||
|
params.add("birthdate", new DateParam("2011-01-01"));
|
||||||
|
|
||||||
|
IBundleProvider results = myPatientDao.search(params, mySrd);
|
||||||
|
assertThat(toUnqualifiedVersionlessIdValues(results)).containsExactlyInAnyOrder(pId);
|
||||||
|
myCaptureQueriesListener.logFirstSelectQueryForCurrentThread();
|
||||||
|
String unformattedSql = myCaptureQueriesListener.getSelectQueriesForCurrentThread().get(0).getSql(true, false);
|
||||||
|
assertThat(unformattedSql).doesNotContain("HFJ_IDX_CMP_STRING_UNIQ");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUniqueComboSearchWithDateTimeNotUsingUniqueIndex() {
|
||||||
|
createUniqueObservationDateCode();
|
||||||
|
|
||||||
|
Observation obs = new Observation();
|
||||||
|
obs.getCode().addCoding().setSystem("foo").setCode("bar");
|
||||||
|
obs.setEffective(new DateTimeType("2017-10-10T00:00:00"));
|
||||||
|
String obsId = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
|
myCaptureQueriesListener.clear();
|
||||||
|
SearchParameterMap params = new SearchParameterMap();
|
||||||
|
params.setLoadSynchronousUpTo(100);
|
||||||
|
params.add("code", new TokenParam("foo", "bar"));
|
||||||
|
params.add("date", new DateParam("2017-10-10T00:00:00"));
|
||||||
|
|
||||||
|
IBundleProvider results = myObservationDao.search(params, mySrd);
|
||||||
|
assertThat(toUnqualifiedVersionlessIdValues(results)).containsExactlyInAnyOrder(obsId);
|
||||||
|
myCaptureQueriesListener.logFirstSelectQueryForCurrentThread();
|
||||||
|
String unformattedSql = myCaptureQueriesListener.getSelectQueriesForCurrentThread().get(0).getSql(true, false);
|
||||||
|
assertThat(unformattedSql).doesNotContain("HFJ_IDX_CMP_STRING_UNIQ");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReplaceOneWithAnother() {
|
||||||
|
myStorageSettings.setAdvancedHSearchIndexing(false);
|
||||||
|
createUniqueGenderFamilyComboSp();
|
||||||
|
|
||||||
|
Patient pt1 = new Patient();
|
||||||
|
pt1.setGender(Enumerations.AdministrativeGender.MALE);
|
||||||
|
pt1.getName().add(new HumanName().setFamily("Family1"));
|
||||||
IIdType id1 = myPatientDao.create(pt1, mySrd).getId().toUnqualified();
|
IIdType id1 = myPatientDao.create(pt1, mySrd).getId().toUnqualified();
|
||||||
assertNotNull(id1);
|
assertNotNull(id1);
|
||||||
|
|
||||||
|
@ -1714,27 +1869,28 @@ public class FhirResourceDaoR4ComboUniqueParamTest extends BaseComboParamsR4Test
|
||||||
pt1 = new Patient();
|
pt1 = new Patient();
|
||||||
pt1.setId(id1);
|
pt1.setId(id1);
|
||||||
pt1.setGender(Enumerations.AdministrativeGender.FEMALE);
|
pt1.setGender(Enumerations.AdministrativeGender.FEMALE);
|
||||||
pt1.setBirthDateElement(new DateType("2011-01-01"));
|
pt1.getName().add(new HumanName().setFamily("Family1"));
|
||||||
id1 = myPatientDao.update(pt1, mySrd).getId().toUnqualified();
|
id1 = myPatientDao.update(pt1, mySrd).getId().toUnqualified();
|
||||||
assertNotNull(id1);
|
assertNotNull(id1);
|
||||||
assertEquals("2", id1.getVersionIdPart());
|
assertEquals("2", id1.getVersionIdPart());
|
||||||
|
|
||||||
Patient pt2 = new Patient();
|
Patient pt2 = new Patient();
|
||||||
pt2.setGender(Enumerations.AdministrativeGender.MALE);
|
pt2.setGender(Enumerations.AdministrativeGender.MALE);
|
||||||
pt2.setBirthDateElement(new DateType("2011-01-01"));
|
pt2.getName().add(new HumanName().setFamily("Family1"));
|
||||||
IIdType id2 = myPatientDao.create(pt2, mySrd).getId().toUnqualifiedVersionless();
|
IIdType id2 = myPatientDao.create(pt2, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
myMessages.clear();
|
myMessages.clear();
|
||||||
SearchParameterMap params = new SearchParameterMap();
|
SearchParameterMap params = new SearchParameterMap();
|
||||||
params.add("gender", new TokenParam("http://hl7.org/fhir/administrative-gender", "male"));
|
params.add("gender", new TokenParam("http://hl7.org/fhir/administrative-gender", "male"));
|
||||||
params.add("birthdate", new DateParam("2011-01-01"));
|
params.add("family", new StringParam("Family1"));
|
||||||
IBundleProvider results = myPatientDao.search(params, mySrd);
|
IBundleProvider results = myPatientDao.search(params, mySrd);
|
||||||
String searchId = results.getUuid();
|
String searchId = results.getUuid();
|
||||||
assertThat(searchId).isNotBlank();
|
assertThat(searchId).isNotBlank();
|
||||||
assertThat(toUnqualifiedVersionlessIdValues(results)).containsExactlyInAnyOrder(id2.getValue());
|
assertThat(toUnqualifiedVersionlessIdValues(results)).containsExactlyInAnyOrder(id2.getValue());
|
||||||
|
|
||||||
logCapturedMessages();
|
logCapturedMessages();
|
||||||
assertThat(myMessages.toString()).contains("Using UNIQUE index(es) for query for search: Patient?birthdate=2011-01-01&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale");
|
assertThat(myMessages.toString()).contains("Using UNIQUE index(es) for query for search: " +
|
||||||
|
"Patient?family=Family1&gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale");
|
||||||
myMessages.clear();
|
myMessages.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package ca.uhn.fhir.jpa.dao.r4;
|
package ca.uhn.fhir.jpa.dao.r4;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import ca.uhn.fhir.i18n.Msg;
|
|
||||||
import ca.uhn.fhir.jpa.api.config.JpaStorageSettings;
|
|
||||||
import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel;
|
import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel;
|
||||||
|
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamCoords;
|
||||||
|
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamQuantity;
|
||||||
|
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamQuantityNormalized;
|
||||||
|
import ca.uhn.fhir.jpa.model.entity.StorageSettings;
|
||||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||||
import ca.uhn.fhir.jpa.test.BaseJpaR4Test;
|
import ca.uhn.fhir.jpa.test.BaseJpaR4Test;
|
||||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||||
|
@ -12,7 +13,6 @@ import ca.uhn.fhir.rest.param.QuantityParam;
|
||||||
import ca.uhn.fhir.rest.param.ReferenceParam;
|
import ca.uhn.fhir.rest.param.ReferenceParam;
|
||||||
import ca.uhn.fhir.rest.param.StringParam;
|
import ca.uhn.fhir.rest.param.StringParam;
|
||||||
import ca.uhn.fhir.rest.param.TokenParam;
|
import ca.uhn.fhir.rest.param.TokenParam;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException;
|
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.hl7.fhir.r4.model.DateType;
|
import org.hl7.fhir.r4.model.DateType;
|
||||||
import org.hl7.fhir.r4.model.DecimalType;
|
import org.hl7.fhir.r4.model.DecimalType;
|
||||||
|
@ -26,57 +26,25 @@ import org.hl7.fhir.r4.model.Reference;
|
||||||
import org.hl7.fhir.r4.model.Task;
|
import org.hl7.fhir.r4.model.Task;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Nested;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
public class FhirResourceDaoR4SearchMissingTest {
|
||||||
private static final Logger ourLog = LoggerFactory.getLogger(FhirResourceDaoR4SearchMissingTest.class);
|
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
class IndexMissingDisabledTests extends MissingTests {
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void beforeResetMissing() {
|
public void before() {
|
||||||
myStorageSettings.setIndexMissingFields(JpaStorageSettings.IndexEnabledEnum.ENABLED);
|
myStorageSettings.setIndexMissingFields(StorageSettings.IndexEnabledEnum.DISABLED);
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
public void afterResetSearch() {
|
|
||||||
myStorageSettings.setNormalizedQuantitySearchLevel(NormalizedQuantitySearchLevel.NORMALIZED_QUANTITY_SEARCH_NOT_SUPPORTED);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testIndexMissingFieldsDisabledDontAllowInSearch_NonReference() {
|
|
||||||
myStorageSettings.setIndexMissingFields(JpaStorageSettings.IndexEnabledEnum.DISABLED);
|
|
||||||
|
|
||||||
SearchParameterMap params = new SearchParameterMap();
|
|
||||||
params.add(Patient.SP_ACTIVE, new StringParam().setMissing(true));
|
|
||||||
try {
|
|
||||||
myPatientDao.search(params);
|
|
||||||
} catch (MethodNotAllowedException e) {
|
|
||||||
assertEquals(Msg.code(985) + ":missing modifier is disabled on this server", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testIndexMissingFieldsDisabledDontAllowInSearch_Reference() {
|
|
||||||
myStorageSettings.setIndexMissingFields(JpaStorageSettings.IndexEnabledEnum.DISABLED);
|
|
||||||
|
|
||||||
SearchParameterMap params = new SearchParameterMap();
|
|
||||||
params.add(Patient.SP_ORGANIZATION, new StringParam().setMissing(true));
|
|
||||||
try {
|
|
||||||
myPatientDao.search(params);
|
|
||||||
} catch (MethodNotAllowedException e) {
|
|
||||||
assertEquals(Msg.code(985) + ":missing modifier is disabled on this server", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIndexMissingFieldsDisabledDontCreateIndexes() {
|
public void testIndexMissingFieldsDisabledDontCreateIndexes() {
|
||||||
myStorageSettings.setIndexMissingFields(JpaStorageSettings.IndexEnabledEnum.DISABLED);
|
|
||||||
Organization org = new Organization();
|
Organization org = new Organization();
|
||||||
org.setActive(true);
|
org.setActive(true);
|
||||||
myOrganizationDao.create(org, mySrd).getId().toUnqualifiedVersionless();
|
myOrganizationDao.create(org, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
@ -93,8 +61,6 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIndexMissingFieldsDisabledDontCreateIndexesWithNormalizedQuantitySearchSupported() {
|
public void testIndexMissingFieldsDisabledDontCreateIndexesWithNormalizedQuantitySearchSupported() {
|
||||||
|
|
||||||
myStorageSettings.setIndexMissingFields(JpaStorageSettings.IndexEnabledEnum.DISABLED);
|
|
||||||
myStorageSettings.setNormalizedQuantitySearchLevel(NormalizedQuantitySearchLevel.NORMALIZED_QUANTITY_SEARCH_SUPPORTED);
|
myStorageSettings.setNormalizedQuantitySearchLevel(NormalizedQuantitySearchLevel.NORMALIZED_QUANTITY_SEARCH_SUPPORTED);
|
||||||
Organization org = new Organization();
|
Organization org = new Organization();
|
||||||
org.setActive(true);
|
org.setActive(true);
|
||||||
|
@ -112,8 +78,6 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIndexMissingFieldsDisabledDontCreateIndexesWithNormalizedQuantityStorageSupported() {
|
public void testIndexMissingFieldsDisabledDontCreateIndexesWithNormalizedQuantityStorageSupported() {
|
||||||
|
|
||||||
myStorageSettings.setIndexMissingFields(JpaStorageSettings.IndexEnabledEnum.DISABLED);
|
|
||||||
myStorageSettings.setNormalizedQuantitySearchLevel(NormalizedQuantitySearchLevel.NORMALIZED_QUANTITY_STORAGE_SUPPORTED);
|
myStorageSettings.setNormalizedQuantitySearchLevel(NormalizedQuantitySearchLevel.NORMALIZED_QUANTITY_STORAGE_SUPPORTED);
|
||||||
Organization org = new Organization();
|
Organization org = new Organization();
|
||||||
org.setActive(true);
|
org.setActive(true);
|
||||||
|
@ -128,6 +92,15 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
class IndexMissingEnabledTests extends MissingTests {
|
||||||
|
@BeforeEach
|
||||||
|
public void before() {
|
||||||
|
myStorageSettings.setIndexMissingFields(StorageSettings.IndexEnabledEnum.ENABLED);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Test
|
@Test
|
||||||
|
@ -144,11 +117,10 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
task.setRequester(new Reference(oid1));
|
task.setRequester(new Reference(oid1));
|
||||||
tid1 = myTaskDao.create(task, mySrd).getId().toUnqualifiedVersionless();
|
tid1 = myTaskDao.create(task, mySrd).getId().toUnqualifiedVersionless();
|
||||||
}
|
}
|
||||||
IIdType tid2;
|
|
||||||
{
|
{
|
||||||
Task task = new Task();
|
Task task = new Task();
|
||||||
task.setOwner(new Reference(oid1));
|
task.setOwner(new Reference(oid1));
|
||||||
tid2 = myTaskDao.create(task, mySrd).getId().toUnqualifiedVersionless();
|
myTaskDao.create(task, mySrd).getId().toUnqualifiedVersionless();
|
||||||
}
|
}
|
||||||
|
|
||||||
IIdType oid2;
|
IIdType oid2;
|
||||||
|
@ -170,27 +142,36 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
|
|
||||||
map = new SearchParameterMap();
|
map = new SearchParameterMap();
|
||||||
map.add(Organization.SP_NAME, new StringParam().setMissing(true));
|
map.add(Organization.SP_NAME, new StringParam().setMissing(true));
|
||||||
ids = toUnqualifiedVersionlessIds(myOrganizationDao.search(map));
|
ids = toUnqualifiedVersionlessIds(myOrganizationDao.search(map, mySrd));
|
||||||
assertThat(ids).containsExactly(oid1);
|
assertThat(ids).containsExactly(oid1);
|
||||||
|
|
||||||
ourLog.info("Starting Search 2");
|
ourLog.info("Starting Search 2");
|
||||||
|
|
||||||
map = new SearchParameterMap();
|
map = new SearchParameterMap();
|
||||||
map.add(Task.SP_REQUESTER, new ReferenceParam("Organization", "name:missing", "true"));
|
map.add(Task.SP_REQUESTER, new ReferenceParam("Organization", "name:missing", "true"));
|
||||||
ids = toUnqualifiedVersionlessIds(myTaskDao.search(map));
|
ids = toUnqualifiedVersionlessIds(myTaskDao.search(map, mySrd));
|
||||||
assertThat(ids).containsExactly(tid1); // NOT tid2
|
assertThat(ids).containsExactly(tid1); // NOT tid2
|
||||||
|
|
||||||
map = new SearchParameterMap();
|
map = new SearchParameterMap();
|
||||||
map.add(Task.SP_REQUESTER, new ReferenceParam("Organization", "name:missing", "false"));
|
map.add(Task.SP_REQUESTER, new ReferenceParam("Organization", "name:missing", "false"));
|
||||||
ids = toUnqualifiedVersionlessIds(myTaskDao.search(map));
|
ids = toUnqualifiedVersionlessIds(myTaskDao.search(map, mySrd));
|
||||||
assertThat(ids).containsExactly(tid3);
|
assertThat(ids).containsExactly(tid3);
|
||||||
|
|
||||||
map = new SearchParameterMap();
|
map = new SearchParameterMap();
|
||||||
map.add(Patient.SP_ORGANIZATION, new ReferenceParam("Organization", "name:missing", "true"));
|
map.add(Patient.SP_ORGANIZATION, new ReferenceParam("Organization", "name:missing", "true"));
|
||||||
ids = toUnqualifiedVersionlessIds(myPatientDao.search(map));
|
ids = toUnqualifiedVersionlessIds(myPatientDao.search(map, mySrd));
|
||||||
assertThat(ids).isEmpty();
|
assertThat(ids).isEmpty();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static class MissingTests extends BaseJpaR4Test {
|
||||||
|
@AfterEach
|
||||||
|
public void after() {
|
||||||
|
myStorageSettings.setIndexMissingFields(new StorageSettings().getIndexMissingFields());
|
||||||
|
myStorageSettings.setNormalizedQuantitySearchLevel(new StorageSettings().getNormalizedQuantitySearchLevel());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSearchWithMissingDate() {
|
public void testSearchWithMissingDate() {
|
||||||
|
@ -217,7 +198,7 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
DateParam param = new DateParam();
|
DateParam param = new DateParam();
|
||||||
param.setMissing(false);
|
param.setMissing(false);
|
||||||
params.add(Patient.SP_BIRTHDATE, param);
|
params.add(Patient.SP_BIRTHDATE, param);
|
||||||
List<IIdType> patients = toUnqualifiedVersionlessIds(myPatientDao.search(params));
|
List<IIdType> patients = toUnqualifiedVersionlessIds(myPatientDao.search(params, mySrd));
|
||||||
assertThat(patients).containsSubsequence(notMissing);
|
assertThat(patients).containsSubsequence(notMissing);
|
||||||
assertThat(patients).doesNotContainSubsequence(missing);
|
assertThat(patients).doesNotContainSubsequence(missing);
|
||||||
}
|
}
|
||||||
|
@ -227,7 +208,7 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
DateParam param = new DateParam();
|
DateParam param = new DateParam();
|
||||||
param.setMissing(true);
|
param.setMissing(true);
|
||||||
params.add(Patient.SP_BIRTHDATE, param);
|
params.add(Patient.SP_BIRTHDATE, param);
|
||||||
List<IIdType> patients = toUnqualifiedVersionlessIds(myPatientDao.search(params));
|
List<IIdType> patients = toUnqualifiedVersionlessIds(myPatientDao.search(params, mySrd));
|
||||||
assertThat(patients).containsSubsequence(missing);
|
assertThat(patients).containsSubsequence(missing);
|
||||||
assertThat(patients).doesNotContainSubsequence(notMissing);
|
assertThat(patients).doesNotContainSubsequence(notMissing);
|
||||||
}
|
}
|
||||||
|
@ -238,9 +219,11 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
String locId = myLocationDao.create(new Location(), mySrd).getId().toUnqualifiedVersionless().getValue();
|
String locId = myLocationDao.create(new Location(), mySrd).getId().toUnqualifiedVersionless().getValue();
|
||||||
String locId2 = myLocationDao.create(new Location().setPosition(new Location.LocationPositionComponent(new DecimalType(10), new DecimalType(10))), mySrd).getId().toUnqualifiedVersionless().getValue();
|
String locId2 = myLocationDao.create(new Location().setPosition(new Location.LocationPositionComponent(new DecimalType(10), new DecimalType(10))), mySrd).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
runInTransaction(() -> {
|
runInTransaction(() -> ourLog.info("Coords:\n * {}",
|
||||||
ourLog.info("Coords:\n * {}", myResourceIndexedSearchParamCoordsDao.findAll().stream().map(t -> t.toString()).collect(Collectors.joining("\n * ")));
|
myResourceIndexedSearchParamCoordsDao.findAll().stream()
|
||||||
});
|
.map(ResourceIndexedSearchParamCoords::toString).collect(Collectors.joining("\n * "))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
{
|
{
|
||||||
SearchParameterMap params = new SearchParameterMap();
|
SearchParameterMap params = new SearchParameterMap();
|
||||||
|
@ -249,7 +232,7 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
param.setMissing(true);
|
param.setMissing(true);
|
||||||
params.add(Location.SP_NEAR, param);
|
params.add(Location.SP_NEAR, param);
|
||||||
myCaptureQueriesListener.clear();
|
myCaptureQueriesListener.clear();
|
||||||
List<String> patients = toUnqualifiedVersionlessIdValues(myLocationDao.search(params));
|
List<String> patients = toUnqualifiedVersionlessIdValues(myLocationDao.search(params, mySrd));
|
||||||
myCaptureQueriesListener.logSelectQueriesForCurrentThread(0);
|
myCaptureQueriesListener.logSelectQueriesForCurrentThread(0);
|
||||||
assertThat(patients).containsSubsequence(locId);
|
assertThat(patients).containsSubsequence(locId);
|
||||||
assertThat(patients).doesNotContainSubsequence(locId2);
|
assertThat(patients).doesNotContainSubsequence(locId2);
|
||||||
|
@ -260,7 +243,7 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
TokenParam param = new TokenParam();
|
TokenParam param = new TokenParam();
|
||||||
param.setMissing(false);
|
param.setMissing(false);
|
||||||
params.add(Location.SP_NEAR, param);
|
params.add(Location.SP_NEAR, param);
|
||||||
List<String> patients = toUnqualifiedVersionlessIdValues(myLocationDao.search(params));
|
List<String> patients = toUnqualifiedVersionlessIdValues(myLocationDao.search(params, mySrd));
|
||||||
assertThat(patients).containsSubsequence(locId2);
|
assertThat(patients).containsSubsequence(locId2);
|
||||||
assertThat(patients).doesNotContainSubsequence(locId);
|
assertThat(patients).doesNotContainSubsequence(locId);
|
||||||
}
|
}
|
||||||
|
@ -271,15 +254,15 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
MedicationRequest mr1 = new MedicationRequest();
|
MedicationRequest mr1 = new MedicationRequest();
|
||||||
mr1.addCategory().addCoding().setSystem("urn:medicationroute").setCode("oral");
|
mr1.addCategory().addCoding().setSystem("urn:medicationroute").setCode("oral");
|
||||||
mr1.addDosageInstruction().getTiming().addEventElement().setValueAsString("2017-01-01");
|
mr1.addDosageInstruction().getTiming().addEventElement().setValueAsString("2017-01-01");
|
||||||
IIdType id1 = myMedicationRequestDao.create(mr1).getId().toUnqualifiedVersionless();
|
myMedicationRequestDao.create(mr1, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
MedicationRequest mr2 = new MedicationRequest();
|
MedicationRequest mr2 = new MedicationRequest();
|
||||||
mr2.addCategory().addCoding().setSystem("urn:medicationroute").setCode("oral");
|
mr2.addCategory().addCoding().setSystem("urn:medicationroute").setCode("oral");
|
||||||
IIdType id2 = myMedicationRequestDao.create(mr2).getId().toUnqualifiedVersionless();
|
IIdType id2 = myMedicationRequestDao.create(mr2, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
SearchParameterMap map = new SearchParameterMap();
|
SearchParameterMap map = new SearchParameterMap();
|
||||||
map.add(MedicationRequest.SP_DATE, new DateParam().setMissing(true));
|
map.add(MedicationRequest.SP_DATE, new DateParam().setMissing(true));
|
||||||
IBundleProvider results = myMedicationRequestDao.search(map);
|
IBundleProvider results = myMedicationRequestDao.search(map, mySrd);
|
||||||
List<String> ids = toUnqualifiedVersionlessIdValues(results);
|
List<String> ids = toUnqualifiedVersionlessIdValues(results);
|
||||||
|
|
||||||
assertThat(ids).containsExactly(id2.getValue());
|
assertThat(ids).containsExactly(id2.getValue());
|
||||||
|
@ -308,7 +291,7 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
QuantityParam param = new QuantityParam();
|
QuantityParam param = new QuantityParam();
|
||||||
param.setMissing(false);
|
param.setMissing(false);
|
||||||
params.add(Observation.SP_VALUE_QUANTITY, param);
|
params.add(Observation.SP_VALUE_QUANTITY, param);
|
||||||
List<IIdType> patients = toUnqualifiedVersionlessIds(myObservationDao.search(params));
|
List<IIdType> patients = toUnqualifiedVersionlessIds(myObservationDao.search(params, mySrd));
|
||||||
assertThat(patients).doesNotContainSubsequence(missing);
|
assertThat(patients).doesNotContainSubsequence(missing);
|
||||||
assertThat(patients).containsSubsequence(notMissing);
|
assertThat(patients).containsSubsequence(notMissing);
|
||||||
}
|
}
|
||||||
|
@ -318,7 +301,7 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
QuantityParam param = new QuantityParam();
|
QuantityParam param = new QuantityParam();
|
||||||
param.setMissing(true);
|
param.setMissing(true);
|
||||||
params.add(Observation.SP_VALUE_QUANTITY, param);
|
params.add(Observation.SP_VALUE_QUANTITY, param);
|
||||||
List<IIdType> patients = toUnqualifiedVersionlessIds(myObservationDao.search(params));
|
List<IIdType> patients = toUnqualifiedVersionlessIds(myObservationDao.search(params, mySrd));
|
||||||
assertThat(patients).containsSubsequence(missing);
|
assertThat(patients).containsSubsequence(missing);
|
||||||
assertThat(patients).doesNotContainSubsequence(notMissing);
|
assertThat(patients).doesNotContainSubsequence(notMissing);
|
||||||
}
|
}
|
||||||
|
@ -343,8 +326,16 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
runInTransaction(() -> {
|
runInTransaction(() -> {
|
||||||
ourLog.info("Quantity Indexes:\n * {}", myResourceIndexedSearchParamQuantityDao.findAll().stream().filter(t -> t.getParamName().equals("value-quantity")).map(t -> t.toString()).collect(Collectors.joining("\n * ")));
|
ourLog.info("Quantity Indexes:\n * {}",
|
||||||
ourLog.info("Normalized Quantity Indexes:\n * {}", myResourceIndexedSearchParamQuantityNormalizedDao.findAll().stream().filter(t -> t.getParamName().equals("value-quantity")).map(t -> t.toString()).collect(Collectors.joining("\n * ")));
|
myResourceIndexedSearchParamQuantityDao.findAll().stream()
|
||||||
|
.filter(t -> t.getParamName().equals("value-quantity")).map(ResourceIndexedSearchParamQuantity::toString).collect(Collectors.joining("\n * ")
|
||||||
|
)
|
||||||
|
);
|
||||||
|
ourLog.info("Normalized Quantity Indexes:\n * {}",
|
||||||
|
myResourceIndexedSearchParamQuantityNormalizedDao.findAll().stream().
|
||||||
|
filter(t -> t.getParamName().equals("value-quantity")).map(ResourceIndexedSearchParamQuantityNormalized::toString).collect(Collectors.joining("\n * ")
|
||||||
|
)
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Quantity Param
|
// Quantity Param
|
||||||
|
@ -354,7 +345,7 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
QuantityParam param = new QuantityParam();
|
QuantityParam param = new QuantityParam();
|
||||||
param.setMissing(false);
|
param.setMissing(false);
|
||||||
params.add(Observation.SP_VALUE_QUANTITY, param);
|
params.add(Observation.SP_VALUE_QUANTITY, param);
|
||||||
List<IIdType> patients = toUnqualifiedVersionlessIds(myObservationDao.search(params));
|
List<IIdType> patients = toUnqualifiedVersionlessIds(myObservationDao.search(params, mySrd));
|
||||||
assertThat(patients).doesNotContainSubsequence(missing);
|
assertThat(patients).doesNotContainSubsequence(missing);
|
||||||
assertThat(patients).containsSubsequence(notMissing);
|
assertThat(patients).containsSubsequence(notMissing);
|
||||||
}
|
}
|
||||||
|
@ -365,7 +356,7 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
param.setMissing(true);
|
param.setMissing(true);
|
||||||
params.add(Observation.SP_VALUE_QUANTITY, param);
|
params.add(Observation.SP_VALUE_QUANTITY, param);
|
||||||
myCaptureQueriesListener.clear();
|
myCaptureQueriesListener.clear();
|
||||||
List<IIdType> patients = toUnqualifiedVersionlessIds(myObservationDao.search(params));
|
List<IIdType> patients = toUnqualifiedVersionlessIds(myObservationDao.search(params, mySrd));
|
||||||
myCaptureQueriesListener.logSelectQueries();
|
myCaptureQueriesListener.logSelectQueries();
|
||||||
assertThat(patients).containsSubsequence(missing);
|
assertThat(patients).containsSubsequence(missing);
|
||||||
assertThat(patients).doesNotContainSubsequence(notMissing);
|
assertThat(patients).doesNotContainSubsequence(notMissing);
|
||||||
|
@ -397,7 +388,7 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
QuantityParam param = new QuantityParam();
|
QuantityParam param = new QuantityParam();
|
||||||
param.setMissing(false);
|
param.setMissing(false);
|
||||||
params.add(Observation.SP_VALUE_QUANTITY, param);
|
params.add(Observation.SP_VALUE_QUANTITY, param);
|
||||||
List<IIdType> patients = toUnqualifiedVersionlessIds(myObservationDao.search(params));
|
List<IIdType> patients = toUnqualifiedVersionlessIds(myObservationDao.search(params, mySrd));
|
||||||
assertThat(patients).doesNotContainSubsequence(missing);
|
assertThat(patients).doesNotContainSubsequence(missing);
|
||||||
assertThat(patients).containsSubsequence(notMissing);
|
assertThat(patients).containsSubsequence(notMissing);
|
||||||
}
|
}
|
||||||
|
@ -407,7 +398,7 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
QuantityParam param = new QuantityParam();
|
QuantityParam param = new QuantityParam();
|
||||||
param.setMissing(true);
|
param.setMissing(true);
|
||||||
params.add(Observation.SP_VALUE_QUANTITY, param);
|
params.add(Observation.SP_VALUE_QUANTITY, param);
|
||||||
List<IIdType> patients = toUnqualifiedVersionlessIds(myObservationDao.search(params));
|
List<IIdType> patients = toUnqualifiedVersionlessIds(myObservationDao.search(params, mySrd));
|
||||||
assertThat(patients).containsSubsequence(missing);
|
assertThat(patients).containsSubsequence(missing);
|
||||||
assertThat(patients).doesNotContainSubsequence(notMissing);
|
assertThat(patients).doesNotContainSubsequence(notMissing);
|
||||||
}
|
}
|
||||||
|
@ -440,7 +431,7 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
ReferenceParam param = new ReferenceParam();
|
ReferenceParam param = new ReferenceParam();
|
||||||
param.setMissing(false);
|
param.setMissing(false);
|
||||||
params.add(Patient.SP_ORGANIZATION, param);
|
params.add(Patient.SP_ORGANIZATION, param);
|
||||||
List<IIdType> patients = toUnqualifiedVersionlessIds(myPatientDao.search(params));
|
List<IIdType> patients = toUnqualifiedVersionlessIds(myPatientDao.search(params, mySrd));
|
||||||
assertThat(patients).doesNotContainSubsequence(missing);
|
assertThat(patients).doesNotContainSubsequence(missing);
|
||||||
assertThat(patients).containsSubsequence(notMissing);
|
assertThat(patients).containsSubsequence(notMissing);
|
||||||
}
|
}
|
||||||
|
@ -450,13 +441,36 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
ReferenceParam param = new ReferenceParam();
|
ReferenceParam param = new ReferenceParam();
|
||||||
param.setMissing(true);
|
param.setMissing(true);
|
||||||
params.add(Patient.SP_ORGANIZATION, param);
|
params.add(Patient.SP_ORGANIZATION, param);
|
||||||
List<IIdType> patients = toUnqualifiedVersionlessIds(myPatientDao.search(params));
|
List<IIdType> patients = toUnqualifiedVersionlessIds(myPatientDao.search(params, mySrd));
|
||||||
assertThat(patients).containsSubsequence(missing);
|
assertThat(patients).containsSubsequence(missing);
|
||||||
assertThat(patients).doesNotContainSubsequence(notMissing);
|
assertThat(patients).doesNotContainSubsequence(notMissing);
|
||||||
assertThat(patients).doesNotContainSubsequence(orgId);
|
assertThat(patients).doesNotContainSubsequence(orgId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSearchWithMissingReference_resourceTypeWithMultipleReferences() {
|
||||||
|
IIdType patientId = createPatient();
|
||||||
|
IIdType observationId = createObservation(withSubject(patientId));
|
||||||
|
|
||||||
|
SearchParameterMap params = new SearchParameterMap();
|
||||||
|
params.add(Observation.SP_PERFORMER, new ReferenceParam().setMissing(true));
|
||||||
|
IBundleProvider bundleProvider = myObservationDao.search(params, mySrd);
|
||||||
|
assertThat(bundleProvider.getAllResourceIds()).containsExactly(observationId.getIdPart());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSearchWithMissingReference_searchParamMultiplePaths() {
|
||||||
|
IIdType encounterId = createEncounter();
|
||||||
|
createObservation(withEncounter(encounterId.getValue()));
|
||||||
|
|
||||||
|
SearchParameterMap params = new SearchParameterMap();
|
||||||
|
params.add(Observation.SP_ENCOUNTER, new ReferenceParam().setMissing(true));
|
||||||
|
IBundleProvider bundleProvider = myObservationDao.search(params, mySrd);
|
||||||
|
assertThat(bundleProvider.getAllResourceIds()).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSearchWithMissingString() {
|
public void testSearchWithMissingString() {
|
||||||
IIdType orgId = myOrganizationDao.create(new Organization(), mySrd).getId();
|
IIdType orgId = myOrganizationDao.create(new Organization(), mySrd).getId();
|
||||||
|
@ -482,7 +496,7 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
StringParam param = new StringParam();
|
StringParam param = new StringParam();
|
||||||
param.setMissing(false);
|
param.setMissing(false);
|
||||||
params.add(Patient.SP_FAMILY, param);
|
params.add(Patient.SP_FAMILY, param);
|
||||||
List<IIdType> patients = toUnqualifiedVersionlessIds(myPatientDao.search(params));
|
List<IIdType> patients = toUnqualifiedVersionlessIds(myPatientDao.search(params, mySrd));
|
||||||
assertThat(patients).doesNotContainSubsequence(missing);
|
assertThat(patients).doesNotContainSubsequence(missing);
|
||||||
assertThat(patients).containsSubsequence(notMissing);
|
assertThat(patients).containsSubsequence(notMissing);
|
||||||
}
|
}
|
||||||
|
@ -492,7 +506,7 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
StringParam param = new StringParam();
|
StringParam param = new StringParam();
|
||||||
param.setMissing(true);
|
param.setMissing(true);
|
||||||
params.add(Patient.SP_FAMILY, param);
|
params.add(Patient.SP_FAMILY, param);
|
||||||
List<IIdType> patients = toUnqualifiedVersionlessIds(myPatientDao.search(params));
|
List<IIdType> patients = toUnqualifiedVersionlessIds(myPatientDao.search(params, mySrd));
|
||||||
assertThat(patients).containsSubsequence(missing);
|
assertThat(patients).containsSubsequence(missing);
|
||||||
assertThat(patients).doesNotContainSubsequence(notMissing);
|
assertThat(patients).doesNotContainSubsequence(notMissing);
|
||||||
}
|
}
|
||||||
|
@ -520,7 +534,7 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
TokenParam param = new TokenParam();
|
TokenParam param = new TokenParam();
|
||||||
param.setMissing(false);
|
param.setMissing(false);
|
||||||
params.add(Observation.SP_CODE, param);
|
params.add(Observation.SP_CODE, param);
|
||||||
List<IIdType> patients = toUnqualifiedVersionlessIds(myObservationDao.search(params));
|
List<IIdType> patients = toUnqualifiedVersionlessIds(myObservationDao.search(params, mySrd));
|
||||||
assertThat(patients).doesNotContainSubsequence(missing);
|
assertThat(patients).doesNotContainSubsequence(missing);
|
||||||
assertThat(patients).containsSubsequence(notMissing);
|
assertThat(patients).containsSubsequence(notMissing);
|
||||||
}
|
}
|
||||||
|
@ -530,10 +544,11 @@ public class FhirResourceDaoR4SearchMissingTest extends BaseJpaR4Test {
|
||||||
TokenParam param = new TokenParam();
|
TokenParam param = new TokenParam();
|
||||||
param.setMissing(true);
|
param.setMissing(true);
|
||||||
params.add(Observation.SP_CODE, param);
|
params.add(Observation.SP_CODE, param);
|
||||||
List<IIdType> patients = toUnqualifiedVersionlessIds(myObservationDao.search(params));
|
List<IIdType> patients = toUnqualifiedVersionlessIds(myObservationDao.search(params, mySrd));
|
||||||
assertThat(patients).containsSubsequence(missing);
|
assertThat(patients).containsSubsequence(missing);
|
||||||
assertThat(patients).doesNotContainSubsequence(notMissing);
|
assertThat(patients).doesNotContainSubsequence(notMissing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -413,7 +413,7 @@ public class PartitioningSqlR4Test extends BasePartitioningR4Test {
|
||||||
p.getMeta().addTag("http://system", "code", "diisplay");
|
p.getMeta().addTag("http://system", "code", "diisplay");
|
||||||
p.addName().setFamily("FAM");
|
p.addName().setFamily("FAM");
|
||||||
p.addIdentifier().setSystem("system").setValue("value");
|
p.addIdentifier().setSystem("system").setValue("value");
|
||||||
p.setBirthDateElement(new DateType("2020-01-01"));
|
p.setGender(Enumerations.AdministrativeGender.MALE);
|
||||||
p.getManagingOrganization().setReferenceElement(orgId);
|
p.getManagingOrganization().setReferenceElement(orgId);
|
||||||
Long patientId = myPatientDao.create(p, mySrd).getId().getIdPartAsLong();
|
Long patientId = myPatientDao.create(p, mySrd).getId().getIdPartAsLong();
|
||||||
|
|
||||||
|
@ -502,7 +502,7 @@ public class PartitioningSqlR4Test extends BasePartitioningR4Test {
|
||||||
p.getMeta().addTag("http://system", "code", "diisplay");
|
p.getMeta().addTag("http://system", "code", "diisplay");
|
||||||
p.addName().setFamily("FAM");
|
p.addName().setFamily("FAM");
|
||||||
p.addIdentifier().setSystem("system").setValue("value");
|
p.addIdentifier().setSystem("system").setValue("value");
|
||||||
p.setBirthDate(new Date());
|
p.setGender(Enumerations.AdministrativeGender.MALE);
|
||||||
p.getManagingOrganization().setReferenceElement(orgId);
|
p.getManagingOrganization().setReferenceElement(orgId);
|
||||||
Long patientId = myPatientDao.create(p, mySrd).getId().getIdPartAsLong();
|
Long patientId = myPatientDao.create(p, mySrd).getId().getIdPartAsLong();
|
||||||
|
|
||||||
|
@ -679,7 +679,7 @@ public class PartitioningSqlR4Test extends BasePartitioningR4Test {
|
||||||
p.getMeta().addTag("http://system", "code", "display");
|
p.getMeta().addTag("http://system", "code", "display");
|
||||||
p.addName().setFamily("FAM");
|
p.addName().setFamily("FAM");
|
||||||
p.addIdentifier().setSystem("system").setValue("value");
|
p.addIdentifier().setSystem("system").setValue("value");
|
||||||
p.setBirthDate(new Date());
|
p.setGender(Enumerations.AdministrativeGender.MALE);
|
||||||
p.getManagingOrganization().setReference(org.getId());
|
p.getManagingOrganization().setReference(org.getId());
|
||||||
input.addEntry()
|
input.addEntry()
|
||||||
.setFullUrl(p.getId())
|
.setFullUrl(p.getId())
|
||||||
|
@ -2541,14 +2541,14 @@ public class PartitioningSqlR4Test extends BasePartitioningR4Test {
|
||||||
public void testSearch_UniqueParam_SearchAllPartitions() {
|
public void testSearch_UniqueParam_SearchAllPartitions() {
|
||||||
createUniqueComboSp();
|
createUniqueComboSp();
|
||||||
|
|
||||||
IIdType id = createPatient(withPartition(1), withBirthdate("2020-01-01"), withFamily("FAM"));
|
IIdType id = createPatient(withPartition(1), withGender("male"), withFamily("FAM"));
|
||||||
|
|
||||||
addReadAllPartitions();
|
addReadAllPartitions();
|
||||||
|
|
||||||
myCaptureQueriesListener.clear();
|
myCaptureQueriesListener.clear();
|
||||||
SearchParameterMap map = new SearchParameterMap();
|
SearchParameterMap map = new SearchParameterMap();
|
||||||
map.add(Patient.SP_FAMILY, new StringParam("FAM"));
|
map.add(Patient.SP_FAMILY, new StringParam("FAM"));
|
||||||
map.add(Patient.SP_BIRTHDATE, new DateParam("2020-01-01"));
|
map.add(Patient.SP_GENDER, new TokenParam(null, "male"));
|
||||||
map.setLoadSynchronous(true);
|
map.setLoadSynchronous(true);
|
||||||
IBundleProvider results = myPatientDao.search(map, mySrd);
|
IBundleProvider results = myPatientDao.search(map, mySrd);
|
||||||
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
|
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
|
||||||
|
@ -2558,7 +2558,7 @@ public class PartitioningSqlR4Test extends BasePartitioningR4Test {
|
||||||
String searchSql = myCaptureQueriesListener.getSelectQueriesForCurrentThread().get(0).getSql(true, true);
|
String searchSql = myCaptureQueriesListener.getSelectQueriesForCurrentThread().get(0).getSql(true, true);
|
||||||
ourLog.info("Search SQL:\n{}", searchSql);
|
ourLog.info("Search SQL:\n{}", searchSql);
|
||||||
assertThat(searchSql).doesNotContain("PARTITION_ID");
|
assertThat(searchSql).doesNotContain("PARTITION_ID");
|
||||||
assertThat(searchSql).containsOnlyOnce("IDX_STRING = 'Patient?birthdate=2020-01-01&family=FAM'");
|
assertThat(searchSql).containsOnlyOnce("IDX_STRING = 'Patient?family=FAM&gender=male'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2566,13 +2566,13 @@ public class PartitioningSqlR4Test extends BasePartitioningR4Test {
|
||||||
public void testSearch_UniqueParam_SearchOnePartition() {
|
public void testSearch_UniqueParam_SearchOnePartition() {
|
||||||
createUniqueComboSp();
|
createUniqueComboSp();
|
||||||
|
|
||||||
IIdType id = createPatient(withPartition(1), withBirthdate("2020-01-01"), withFamily("FAM"));
|
IIdType id = createPatient(withPartition(1), withGender("male"), withFamily("FAM"));
|
||||||
|
|
||||||
addReadPartition(1);
|
addReadPartition(1);
|
||||||
myCaptureQueriesListener.clear();
|
myCaptureQueriesListener.clear();
|
||||||
SearchParameterMap map = new SearchParameterMap();
|
SearchParameterMap map = new SearchParameterMap();
|
||||||
map.add(Patient.SP_FAMILY, new StringParam("FAM"));
|
map.add(Patient.SP_FAMILY, new StringParam("FAM"));
|
||||||
map.add(Patient.SP_BIRTHDATE, new DateParam("2020-01-01"));
|
map.add(Patient.SP_GENDER, new TokenParam(null, "male"));
|
||||||
map.setLoadSynchronous(true);
|
map.setLoadSynchronous(true);
|
||||||
IBundleProvider results = myPatientDao.search(map, mySrd);
|
IBundleProvider results = myPatientDao.search(map, mySrd);
|
||||||
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
|
List<IIdType> ids = toUnqualifiedVersionlessIds(results);
|
||||||
|
@ -2582,13 +2582,13 @@ public class PartitioningSqlR4Test extends BasePartitioningR4Test {
|
||||||
String searchSql = myCaptureQueriesListener.getSelectQueriesForCurrentThread().get(0).getSql(true, true);
|
String searchSql = myCaptureQueriesListener.getSelectQueriesForCurrentThread().get(0).getSql(true, true);
|
||||||
ourLog.info("Search SQL:\n{}", searchSql);
|
ourLog.info("Search SQL:\n{}", searchSql);
|
||||||
assertThat(searchSql).containsOnlyOnce( "PARTITION_ID = '1'");
|
assertThat(searchSql).containsOnlyOnce( "PARTITION_ID = '1'");
|
||||||
assertThat(searchSql).containsOnlyOnce("IDX_STRING = 'Patient?birthdate=2020-01-01&family=FAM'");
|
assertThat(searchSql).containsOnlyOnce("IDX_STRING = 'Patient?family=FAM&gender=male'");
|
||||||
|
|
||||||
// Same query, different partition
|
// Same query, different partition
|
||||||
addReadPartition(2);
|
addReadPartition(2);
|
||||||
myCaptureQueriesListener.clear();
|
myCaptureQueriesListener.clear();
|
||||||
map = new SearchParameterMap();
|
map = new SearchParameterMap();
|
||||||
map.add(Patient.SP_BIRTHDATE, new DateParam("2020-01-01"));
|
map.add(Patient.SP_GENDER, new TokenParam(null, "male"));
|
||||||
map.setLoadSynchronous(true);
|
map.setLoadSynchronous(true);
|
||||||
results = myPatientDao.search(map, mySrd);
|
results = myPatientDao.search(map, mySrd);
|
||||||
ids = toUnqualifiedVersionlessIds(results);
|
ids = toUnqualifiedVersionlessIds(results);
|
||||||
|
@ -2661,7 +2661,7 @@ public class PartitioningSqlR4Test extends BasePartitioningR4Test {
|
||||||
public void testSearch_RefParam_TargetPid_SearchOnePartition() {
|
public void testSearch_RefParam_TargetPid_SearchOnePartition() {
|
||||||
createUniqueComboSp();
|
createUniqueComboSp();
|
||||||
|
|
||||||
IIdType patientId = createPatient(withPartition(myPartitionId), withBirthdate("2020-01-01"));
|
IIdType patientId = createPatient(withPartition(myPartitionId), withGender("male"));
|
||||||
IIdType observationId = createObservation(withPartition(myPartitionId), withSubject(patientId));
|
IIdType observationId = createObservation(withPartition(myPartitionId), withSubject(patientId));
|
||||||
|
|
||||||
addReadPartition(myPartitionId);
|
addReadPartition(myPartitionId);
|
||||||
|
@ -2698,7 +2698,7 @@ public class PartitioningSqlR4Test extends BasePartitioningR4Test {
|
||||||
public void testSearch_RefParam_TargetPid_SearchDefaultPartition() {
|
public void testSearch_RefParam_TargetPid_SearchDefaultPartition() {
|
||||||
createUniqueComboSp();
|
createUniqueComboSp();
|
||||||
|
|
||||||
IIdType patientId = createPatient(withPartition(null), withBirthdate("2020-01-01"));
|
IIdType patientId = createPatient(withPartition(null), withGender("male"));
|
||||||
IIdType observationId = createObservation(withPartition(null), withSubject(patientId));
|
IIdType observationId = createObservation(withPartition(null), withSubject(patientId));
|
||||||
|
|
||||||
addReadDefaultPartition();
|
addReadDefaultPartition();
|
||||||
|
@ -2735,7 +2735,7 @@ public class PartitioningSqlR4Test extends BasePartitioningR4Test {
|
||||||
public void testSearch_RefParam_TargetForcedId_SearchOnePartition() {
|
public void testSearch_RefParam_TargetForcedId_SearchOnePartition() {
|
||||||
createUniqueComboSp();
|
createUniqueComboSp();
|
||||||
|
|
||||||
IIdType patientId = createPatient(withPartition(myPartitionId), withId("ONE"), withBirthdate("2020-01-01"));
|
IIdType patientId = createPatient(withPartition(myPartitionId), withId("ONE"), withGender("male"));
|
||||||
IIdType observationId = createObservation(withPartition(myPartitionId), withSubject(patientId));
|
IIdType observationId = createObservation(withPartition(myPartitionId), withSubject(patientId));
|
||||||
|
|
||||||
addReadPartition(myPartitionId);
|
addReadPartition(myPartitionId);
|
||||||
|
@ -2805,7 +2805,7 @@ public class PartitioningSqlR4Test extends BasePartitioningR4Test {
|
||||||
public void testSearch_RefParam_TargetForcedId_SearchDefaultPartition() {
|
public void testSearch_RefParam_TargetForcedId_SearchDefaultPartition() {
|
||||||
createUniqueComboSp();
|
createUniqueComboSp();
|
||||||
|
|
||||||
IIdType patientId = createPatient(withPartition(null), withId("ONE"), withBirthdate("2020-01-01"));
|
IIdType patientId = createPatient(withPartition(null), withId("ONE"), withGender("male"));
|
||||||
IIdType observationId = createObservation(withPartition(null), withSubject(patientId));
|
IIdType observationId = createObservation(withPartition(null), withSubject(patientId));
|
||||||
|
|
||||||
addReadDefaultPartition();
|
addReadDefaultPartition();
|
||||||
|
|
|
@ -217,7 +217,7 @@ import static org.mockito.Mockito.when;
|
||||||
public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderR4Test.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderR4Test.class);
|
||||||
private SearchCoordinatorSvcImpl mySearchCoordinatorSvcRaw;
|
private SearchCoordinatorSvcImpl mySearchCoordinatorSvcRaw;
|
||||||
private CapturingInterceptor myCapturingInterceptor = new CapturingInterceptor();
|
private final CapturingInterceptor myCapturingInterceptor = new CapturingInterceptor();
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISearchDao mySearchEntityDao;
|
private ISearchDao mySearchEntityDao;
|
||||||
|
|
||||||
|
@ -413,15 +413,15 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
Patient pt1 = new Patient();
|
Patient pt1 = new Patient();
|
||||||
pt1.addName().setFamily("Elizabeth");
|
pt1.addName().setFamily("Elizabeth");
|
||||||
String pt1id = myPatientDao.create(pt1).getId().toUnqualifiedVersionless().getValue();
|
String pt1id = myPatientDao.create(pt1, mySrd).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
Patient pt2 = new Patient();
|
Patient pt2 = new Patient();
|
||||||
pt2.addName().setFamily("fghijk");
|
pt2.addName().setFamily("fghijk");
|
||||||
String pt2id = myPatientDao.create(pt2).getId().toUnqualifiedVersionless().getValue();
|
String pt2id = myPatientDao.create(pt2, mySrd).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
Patient pt3 = new Patient();
|
Patient pt3 = new Patient();
|
||||||
pt3.addName().setFamily("zzzzz");
|
pt3.addName().setFamily("zzzzz");
|
||||||
myPatientDao.create(pt3).getId().toUnqualifiedVersionless().getValue();
|
myPatientDao.create(pt3, mySrd).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
|
|
||||||
Bundle output = myClient
|
Bundle output = myClient
|
||||||
|
@ -450,7 +450,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
Patient pt1 = new Patient();
|
Patient pt1 = new Patient();
|
||||||
pt1.addName().setFamily("Smith%");
|
pt1.addName().setFamily("Smith%");
|
||||||
String pt1id = myPatientDao.create(pt1).getId().toUnqualifiedVersionless().getValue();
|
String pt1id = myPatientDao.create(pt1, mySrd).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
Bundle output = myClient
|
Bundle output = myClient
|
||||||
.search()
|
.search()
|
||||||
|
@ -463,7 +463,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
Patient pt2 = new Patient();
|
Patient pt2 = new Patient();
|
||||||
pt2.addName().setFamily("Sm%ith");
|
pt2.addName().setFamily("Sm%ith");
|
||||||
String pt2id = myPatientDao.create(pt2).getId().toUnqualifiedVersionless().getValue();
|
String pt2id = myPatientDao.create(pt2, mySrd).getId().toUnqualifiedVersionless().getValue();
|
||||||
|
|
||||||
output = myClient
|
output = myClient
|
||||||
.search()
|
.search()
|
||||||
|
@ -740,7 +740,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
Patient p = new Patient();
|
Patient p = new Patient();
|
||||||
p.addName().setFamily("FAM").addGiven("GIV");
|
p.addName().setFamily("FAM").addGiven("GIV");
|
||||||
IIdType id = myPatientDao.create(p).getId();
|
IIdType id = myPatientDao.create(p, mySrd).getId();
|
||||||
|
|
||||||
myClient.read().resource("Patient").withId(id.toUnqualifiedVersionless()).execute();
|
myClient.read().resource("Patient").withId(id.toUnqualifiedVersionless()).execute();
|
||||||
|
|
||||||
|
@ -763,7 +763,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
Patient p = new Patient();
|
Patient p = new Patient();
|
||||||
p.addName().setFamily("FAM").addGiven("GIV");
|
p.addName().setFamily("FAM").addGiven("GIV");
|
||||||
IIdType id = myPatientDao.create(p).getId().toUnqualifiedVersionless();
|
IIdType id = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
myClient
|
myClient
|
||||||
.delete()
|
.delete()
|
||||||
|
@ -1025,57 +1025,58 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
public void testCreateAndReadBackResourceWithContainedReferenceToContainer() {
|
public void testCreateAndReadBackResourceWithContainedReferenceToContainer() {
|
||||||
myFhirContext.setParserErrorHandler(new StrictErrorHandler());
|
myFhirContext.setParserErrorHandler(new StrictErrorHandler());
|
||||||
|
|
||||||
String input = "{\n" +
|
String input = """
|
||||||
" \"resourceType\": \"Organization\",\n" +
|
{
|
||||||
" \"id\": \"1\",\n" +
|
"resourceType": "Organization",
|
||||||
" \"meta\": {\n" +
|
"id": "1",
|
||||||
" \"tag\": [\n" +
|
"meta": {
|
||||||
" {\n" +
|
"tag": [
|
||||||
" \"system\": \"https://blah.org/deployment\",\n" +
|
{
|
||||||
" \"code\": \"e69414dd-b5c2-462d-bcfd-9d04d6b16596\",\n" +
|
"system": "https://blah.org/deployment",
|
||||||
" \"display\": \"DEPLOYMENT\"\n" +
|
"code": "e69414dd-b5c2-462d-bcfd-9d04d6b16596",
|
||||||
" },\n" +
|
"display": "DEPLOYMENT"
|
||||||
" {\n" +
|
},
|
||||||
" \"system\": \"https://blah.org/region\",\n" +
|
{
|
||||||
" \"code\": \"b47d7a5b-b159-4bed-a8f8-3258e6603adb\",\n" +
|
"system": "https://blah.org/region",
|
||||||
" \"display\": \"REGION\"\n" +
|
"code": "b47d7a5b-b159-4bed-a8f8-3258e6603adb",
|
||||||
" },\n" +
|
"display": "REGION"
|
||||||
" {\n" +
|
},
|
||||||
" \"system\": \"https://blah.org/provider\",\n" +
|
{
|
||||||
" \"code\": \"28c30004-0333-40cf-9e7f-3f9e080930bd\",\n" +
|
"system": "https://blah.org/provider",
|
||||||
" \"display\": \"PROVIDER\"\n" +
|
"code": "28c30004-0333-40cf-9e7f-3f9e080930bd",
|
||||||
" }\n" +
|
"display": "PROVIDER"
|
||||||
" ]\n" +
|
}
|
||||||
" },\n" +
|
]
|
||||||
" \"contained\": [\n" +
|
},
|
||||||
" {\n" +
|
"contained": [
|
||||||
" \"resourceType\": \"Location\",\n" +
|
{
|
||||||
" \"id\": \"2\",\n" +
|
"resourceType": "Location",
|
||||||
" \"position\": {\n" +
|
"id": "2",
|
||||||
" \"longitude\": 51.443238301454289,\n" +
|
"position": {
|
||||||
" \"latitude\": 7.34196905697293\n" +
|
"longitude": 51.443238301454289,
|
||||||
" },\n" +
|
"latitude": 7.34196905697293
|
||||||
" \"managingOrganization\": {\n" +
|
},
|
||||||
" \"reference\": \"#\"\n" +
|
"managingOrganization": {
|
||||||
" }\n" +
|
"reference": "#"
|
||||||
" }\n" +
|
}
|
||||||
" ],\n" +
|
}
|
||||||
" \"type\": [\n" +
|
],
|
||||||
" {\n" +
|
"type": [
|
||||||
" \"coding\": [\n" +
|
{
|
||||||
" {\n" +
|
"coding": [
|
||||||
" \"system\": \"https://blah.org/fmc/OrganizationType\",\n" +
|
{
|
||||||
" \"code\": \"CLINIC\",\n" +
|
"system": "https://blah.org/fmc/OrganizationType",
|
||||||
" \"display\": \"Clinic\"\n" +
|
"code": "CLINIC",
|
||||||
" }\n" +
|
"display": "Clinic"
|
||||||
" ]\n" +
|
}
|
||||||
" }\n" +
|
]
|
||||||
" ],\n" +
|
}
|
||||||
" \"name\": \"testOrg\"\n" +
|
],
|
||||||
"}";
|
"name": "testOrg"
|
||||||
|
}""";
|
||||||
|
|
||||||
Organization org = myFhirContext.newJsonParser().parseResource(Organization.class, input);
|
Organization org = myFhirContext.newJsonParser().parseResource(Organization.class, input);
|
||||||
IIdType id = myOrganizationDao.create(org).getId();
|
IIdType id = myOrganizationDao.create(org, mySrd).getId();
|
||||||
org = myOrganizationDao.read(id);
|
org = myOrganizationDao.read(id);
|
||||||
|
|
||||||
String output = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(org);
|
String output = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(org);
|
||||||
|
@ -1095,9 +1096,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
}
|
}
|
||||||
List<IBaseResource> outcome = myClient.transaction().withResources(resources).prettyPrint().encodedXml().execute();
|
List<IBaseResource> outcome = myClient.transaction().withResources(resources).prettyPrint().encodedXml().execute();
|
||||||
|
|
||||||
runInTransaction(() -> {
|
runInTransaction(() -> assertEquals(100, myResourceTableDao.count()));
|
||||||
assertEquals(100, myResourceTableDao.count());
|
|
||||||
});
|
|
||||||
|
|
||||||
Bundle found = myClient
|
Bundle found = myClient
|
||||||
.search()
|
.search()
|
||||||
|
@ -1306,7 +1305,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateQuestionnaireResponseWithValidation() throws IOException {
|
public void testCreateQuestionnaireResponseWithValidation() {
|
||||||
CodeSystem cs = new CodeSystem();
|
CodeSystem cs = new CodeSystem();
|
||||||
cs.setUrl("http://cs");
|
cs.setUrl("http://cs");
|
||||||
cs.setStatus(Enumerations.PublicationStatus.ACTIVE);
|
cs.setStatus(Enumerations.PublicationStatus.ACTIVE);
|
||||||
|
@ -1906,8 +1905,8 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
* Try it with a raw socket call. The Apache client won't let us use the unescaped "|" in the URL but we want to make sure that works too..
|
* Try it with a raw socket call. The Apache client won't let us use the unescaped "|" in the URL but we want to make sure that works too..
|
||||||
*/
|
*/
|
||||||
Socket sock = new Socket();
|
Socket sock = new Socket();
|
||||||
|
try (sock) {
|
||||||
sock.setSoTimeout(3000);
|
sock.setSoTimeout(3000);
|
||||||
try {
|
|
||||||
sock.connect(new InetSocketAddress("localhost", myPort));
|
sock.connect(new InetSocketAddress("localhost", myPort));
|
||||||
sock.getOutputStream().write(("DELETE /fhir/context/Patient?identifier=http://ghh.org/patient|" + methodName + " HTTP/1.1\n").getBytes(StandardCharsets.UTF_8));
|
sock.getOutputStream().write(("DELETE /fhir/context/Patient?identifier=http://ghh.org/patient|" + methodName + " HTTP/1.1\n").getBytes(StandardCharsets.UTF_8));
|
||||||
sock.getOutputStream().write("Host: localhost\n".getBytes(StandardCharsets.UTF_8));
|
sock.getOutputStream().write("Host: localhost\n".getBytes(StandardCharsets.UTF_8));
|
||||||
|
@ -1915,7 +1914,6 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
BufferedReader socketInput = new BufferedReader(new InputStreamReader(sock.getInputStream()));
|
BufferedReader socketInput = new BufferedReader(new InputStreamReader(sock.getInputStream()));
|
||||||
|
|
||||||
// String response = "";
|
|
||||||
StringBuilder b = new StringBuilder();
|
StringBuilder b = new StringBuilder();
|
||||||
char[] buf = new char[1000];
|
char[] buf = new char[1000];
|
||||||
while (socketInput.read(buf) != -1) {
|
while (socketInput.read(buf) != -1) {
|
||||||
|
@ -1925,9 +1923,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
ourLog.debug("Resp: {}", resp);
|
ourLog.debug("Resp: {}", resp);
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
e.printStackTrace();
|
ourLog.debug(e.getMessage(), e);
|
||||||
} finally {
|
|
||||||
sock.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
|
@ -2398,7 +2394,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
assertThat(idValues).as(idValues.toString()).hasSize(10);
|
assertThat(idValues).as(idValues.toString()).hasSize(10);
|
||||||
|
|
||||||
idValues = searchAndReturnUnqualifiedIdValues(myServerBase + "/_history?_at=gt" + InstantDt.withCurrentTime().getYear());
|
idValues = searchAndReturnUnqualifiedIdValues(myServerBase + "/_history?_at=gt" + InstantDt.withCurrentTime().getYear());
|
||||||
assertThat(idValues).hasSize(0);
|
assertThat(idValues).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2427,7 +2423,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
myMemoryCacheService.invalidateCaches(MemoryCacheService.CacheEnum.PID_TO_FORCED_ID);
|
myMemoryCacheService.invalidateCaches(MemoryCacheService.CacheEnum.PID_TO_FORCED_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bundle history = myClient.history().onInstance(id.getValue()).andReturnBundle(Bundle.class).execute();
|
Bundle history = myClient.history().onInstance(id.getValue()).returnBundle(Bundle.class).execute();
|
||||||
assertEquals(1, history.getEntry().size());
|
assertEquals(1, history.getEntry().size());
|
||||||
BundleEntryComponent historyEntry0 = history.getEntry().get(0);
|
BundleEntryComponent historyEntry0 = history.getEntry().get(0);
|
||||||
// validate entry.fullUrl
|
// validate entry.fullUrl
|
||||||
|
@ -2476,7 +2472,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
myMemoryCacheService.invalidateCaches(MemoryCacheService.CacheEnum.PID_TO_FORCED_ID);
|
myMemoryCacheService.invalidateCaches(MemoryCacheService.CacheEnum.PID_TO_FORCED_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bundle history = myClient.history().onInstance(id.getValue()).andReturnBundle(Bundle.class).execute();
|
Bundle history = myClient.history().onInstance(id.getValue()).returnBundle(Bundle.class).execute();
|
||||||
assertEquals(1, history.getEntry().size());
|
assertEquals(1, history.getEntry().size());
|
||||||
BundleEntryComponent historyEntry0 = history.getEntry().get(0);
|
BundleEntryComponent historyEntry0 = history.getEntry().get(0);
|
||||||
// validate entry.fullUrl
|
// validate entry.fullUrl
|
||||||
|
@ -2508,7 +2504,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
ourLog.info("Res ID: {}", id);
|
ourLog.info("Res ID: {}", id);
|
||||||
|
|
||||||
Bundle history = myClient.history().onInstance(id.getValue()).andReturnBundle(Bundle.class).prettyPrint().summaryMode(SummaryEnum.DATA).execute();
|
Bundle history = myClient.history().onInstance(id.getValue()).returnBundle(Bundle.class).prettyPrint().summaryMode(SummaryEnum.DATA).execute();
|
||||||
assertThat(history.getEntry()).hasSize(3);
|
assertThat(history.getEntry()).hasSize(3);
|
||||||
assertEquals(id.withVersion("3").getValue(), history.getEntry().get(0).getResource().getId());
|
assertEquals(id.withVersion("3").getValue(), history.getEntry().get(0).getResource().getId());
|
||||||
assertThat(((Patient) history.getEntry().get(0).getResource()).getName()).hasSize(1);
|
assertThat(((Patient) history.getEntry().get(0).getResource()).getName()).hasSize(1);
|
||||||
|
@ -2746,7 +2742,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
int total = 20;
|
int total = 20;
|
||||||
Organization org = new Organization();
|
Organization org = new Organization();
|
||||||
org.setName("ORG");
|
org.setName("ORG");
|
||||||
IIdType orgId = myOrganizationDao.create(org).getId().toUnqualifiedVersionless();
|
IIdType orgId = myOrganizationDao.create(org, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
Coding tagCode = new Coding();
|
Coding tagCode = new Coding();
|
||||||
tagCode.setCode("test");
|
tagCode.setCode("test");
|
||||||
|
@ -2757,7 +2753,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
.addTag(tagCode);
|
.addTag(tagCode);
|
||||||
t.setStatus(Task.TaskStatus.REQUESTED);
|
t.setStatus(Task.TaskStatus.REQUESTED);
|
||||||
t.getOwner().setReference(orgId.getValue());
|
t.getOwner().setReference(orgId.getValue());
|
||||||
myTaskDao.create(t);
|
myTaskDao.create(t, mySrd);
|
||||||
}
|
}
|
||||||
HashSet<String> ids = new HashSet<>();
|
HashSet<String> ids = new HashSet<>();
|
||||||
|
|
||||||
|
@ -2835,12 +2831,12 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
if (orgCount > 0) {
|
if (orgCount > 0) {
|
||||||
Organization org = new Organization();
|
Organization org = new Organization();
|
||||||
org.setName("ORG");
|
org.setName("ORG");
|
||||||
IIdType orgId = myOrganizationDao.create(org).getId().toUnqualifiedVersionless();
|
IIdType orgId = myOrganizationDao.create(org, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
orgCount--;
|
orgCount--;
|
||||||
t.getOwner().setReference(orgId.getValue());
|
t.getOwner().setReference(orgId.getValue());
|
||||||
}
|
}
|
||||||
myTaskDao.create(t);
|
myTaskDao.create(t, mySrd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2909,12 +2905,12 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
if (orgCount > 0) {
|
if (orgCount > 0) {
|
||||||
Organization org = new Organization();
|
Organization org = new Organization();
|
||||||
org.setName("ORG");
|
org.setName("ORG");
|
||||||
IIdType orgId = myOrganizationDao.create(org).getId().toUnqualifiedVersionless();
|
IIdType orgId = myOrganizationDao.create(org, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
orgCount--;
|
orgCount--;
|
||||||
t.getOwner().setReference(orgId.getValue());
|
t.getOwner().setReference(orgId.getValue());
|
||||||
}
|
}
|
||||||
myTaskDao.create(t);
|
myTaskDao.create(t, mySrd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2961,13 +2957,13 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
public void testIncludeCountDoesntIncludeIncludes() {
|
public void testIncludeCountDoesntIncludeIncludes() {
|
||||||
Organization org = new Organization();
|
Organization org = new Organization();
|
||||||
org.setName("ORG");
|
org.setName("ORG");
|
||||||
IIdType orgId = myOrganizationDao.create(org).getId().toUnqualifiedVersionless();
|
IIdType orgId = myOrganizationDao.create(org, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
Patient pt = new Patient();
|
Patient pt = new Patient();
|
||||||
pt.getManagingOrganization().setReference(orgId.getValue());
|
pt.getManagingOrganization().setReference(orgId.getValue());
|
||||||
pt.addName().setFamily("FAM" + i);
|
pt.addName().setFamily("FAM" + i);
|
||||||
myPatientDao.create(pt);
|
myPatientDao.create(pt, mySrd);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bundle bundle = myClient
|
Bundle bundle = myClient
|
||||||
|
@ -3168,7 +3164,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
Patient newPt = myClient.read().resource(Patient.class).withId(pid1.getIdPart()).execute();
|
Patient newPt = myClient.read().resource(Patient.class).withId(pid1.getIdPart()).execute();
|
||||||
assertEquals("2", newPt.getIdElement().getVersionIdPart());
|
assertEquals("2", newPt.getIdElement().getVersionIdPart());
|
||||||
assertEquals(false, newPt.getActive());
|
assertFalse(newPt.getActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -3196,7 +3192,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
Patient newPt = myClient.read().resource(Patient.class).withId(pid1.getIdPart()).execute();
|
Patient newPt = myClient.read().resource(Patient.class).withId(pid1.getIdPart()).execute();
|
||||||
assertEquals("1", newPt.getIdElement().getVersionIdPart());
|
assertEquals("1", newPt.getIdElement().getVersionIdPart());
|
||||||
assertEquals(true, newPt.getActive());
|
assertTrue(newPt.getActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -3226,7 +3222,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
Patient newPt = myClient.read().resource(Patient.class).withId(pid1.getIdPart()).execute();
|
Patient newPt = myClient.read().resource(Patient.class).withId(pid1.getIdPart()).execute();
|
||||||
assertEquals("2", newPt.getIdElement().getVersionIdPart());
|
assertEquals("2", newPt.getIdElement().getVersionIdPart());
|
||||||
assertEquals(false, newPt.getActive());
|
assertFalse(newPt.getActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -3255,7 +3251,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
Patient newPt = myClient.read().resource(Patient.class).withId(pid1.getIdPart()).execute();
|
Patient newPt = myClient.read().resource(Patient.class).withId(pid1.getIdPart()).execute();
|
||||||
assertEquals("2", newPt.getIdElement().getVersionIdPart());
|
assertEquals("2", newPt.getIdElement().getVersionIdPart());
|
||||||
assertEquals(false, newPt.getActive());
|
assertFalse(newPt.getActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -3323,12 +3319,12 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
{
|
{
|
||||||
Bundle returned = myClient.search().forResource(Patient.class).encodedXml().returnBundle(Bundle.class).execute();
|
Bundle returned = myClient.search().forResource(Patient.class).encodedXml().returnBundle(Bundle.class).execute();
|
||||||
assertThat(returned.getEntry().size()).isGreaterThan(1);
|
assertThat(returned.getEntry()).hasSizeGreaterThan(1);
|
||||||
assertEquals(BundleType.SEARCHSET, returned.getType());
|
assertEquals(BundleType.SEARCHSET, returned.getType());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Bundle returned = myClient.search().forResource(Patient.class).encodedJson().returnBundle(Bundle.class).execute();
|
Bundle returned = myClient.search().forResource(Patient.class).encodedJson().returnBundle(Bundle.class).execute();
|
||||||
assertThat(returned.getEntry().size()).isGreaterThan(1);
|
assertThat(returned.getEntry()).hasSizeGreaterThan(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3350,7 +3346,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Bundle bundle = myClient.history().onServer().andReturnBundle(Bundle.class).execute();
|
Bundle bundle = myClient.history().onServer().returnBundle(Bundle.class).execute();
|
||||||
assertEquals(1, bundle.getTotal());
|
assertEquals(1, bundle.getTotal());
|
||||||
assertThat(bundle.getEntry()).hasSize(1);
|
assertThat(bundle.getEntry()).hasSize(1);
|
||||||
assertEquals(id2.getIdPart(), bundle.getEntry().get(0).getResource().getIdElement().getIdPart());
|
assertEquals(id2.getIdPart(), bundle.getEntry().get(0).getResource().getIdElement().getIdPart());
|
||||||
|
@ -3507,15 +3503,6 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
assertThat(text).doesNotContain("\"B\"");
|
assertThat(text).doesNotContain("\"B\"");
|
||||||
assertThat(text).doesNotContain("\"B1\"");
|
assertThat(text).doesNotContain("\"B1\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// HttpGet read = new HttpGet(ourServerBase + "/Observation?patient=P5000000302&_sort:desc=code&code:in=http://fkcfhir.org/fhir/vs/ccdacapddialysisorder");
|
|
||||||
// try (CloseableHttpResponse response = ourHttpClient.execute(read)) {
|
|
||||||
// String text = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
|
||||||
// ourLog.info(text);
|
|
||||||
// assertEquals(Constants.STATUS_HTTP_200_OK, response.getStatusLine().getStatusCode());
|
|
||||||
// assertThat(text).doesNotContain("\"text\",\"type\"");
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -3873,9 +3860,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
p.addName().setFamily(methodName + "1");
|
p.addName().setFamily(methodName + "1");
|
||||||
IIdType pid1 = myClient.create().resource(p).execute().getId().toUnqualifiedVersionless();
|
IIdType pid1 = myClient.create().resource(p).execute().getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
Thread.sleep(10);
|
|
||||||
long time1 = System.currentTimeMillis();
|
long time1 = System.currentTimeMillis();
|
||||||
Thread.sleep(10);
|
|
||||||
|
|
||||||
Patient p2 = new Patient();
|
Patient p2 = new Patient();
|
||||||
p2.addName().setFamily(methodName + "2");
|
p2.addName().setFamily(methodName + "2");
|
||||||
|
@ -4064,9 +4049,6 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
public void testSearchLastUpdatedParamRp() throws InterruptedException {
|
public void testSearchLastUpdatedParamRp() throws InterruptedException {
|
||||||
String methodName = "testSearchLastUpdatedParamRp";
|
String methodName = "testSearchLastUpdatedParamRp";
|
||||||
|
|
||||||
int sleep = 100;
|
|
||||||
Thread.sleep(sleep);
|
|
||||||
|
|
||||||
DateTimeType beforeAny = new DateTimeType(new Date(), TemporalPrecisionEnum.MILLI);
|
DateTimeType beforeAny = new DateTimeType(new Date(), TemporalPrecisionEnum.MILLI);
|
||||||
IIdType id1a;
|
IIdType id1a;
|
||||||
{
|
{
|
||||||
|
@ -4083,9 +4065,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
id1b = myClient.create().resource(patient).execute().getId().toUnqualifiedVersionless();
|
id1b = myClient.create().resource(patient).execute().getId().toUnqualifiedVersionless();
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.sleep(1100);
|
|
||||||
DateTimeType beforeR2 = new DateTimeType(new Date(), TemporalPrecisionEnum.MILLI);
|
DateTimeType beforeR2 = new DateTimeType(new Date(), TemporalPrecisionEnum.MILLI);
|
||||||
Thread.sleep(1100);
|
|
||||||
|
|
||||||
IIdType id2;
|
IIdType id2;
|
||||||
{
|
{
|
||||||
|
@ -4249,13 +4229,12 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp);
|
Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp);
|
||||||
matches = bundle.getEntry().size();
|
matches = bundle.getEntry().size();
|
||||||
|
|
||||||
assertThat(matches).isGreaterThan(0);
|
assertThat(matches).isPositive();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSearchReturnsSearchDate() throws Exception {
|
public void testSearchReturnsSearchDate() throws Exception {
|
||||||
Date before = new Date();
|
Date before = new Date();
|
||||||
Thread.sleep(1);
|
|
||||||
|
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
Bundle found = myClient
|
Bundle found = myClient
|
||||||
|
@ -4266,7 +4245,6 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
.execute();
|
.execute();
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
|
|
||||||
Thread.sleep(1);
|
|
||||||
Date after = new Date();
|
Date after = new Date();
|
||||||
|
|
||||||
InstantType updated = found.getMeta().getLastUpdatedElement();
|
InstantType updated = found.getMeta().getLastUpdatedElement();
|
||||||
|
@ -4300,7 +4278,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
myObservationDao.create(obs, mySrd);
|
myObservationDao.create(obs, mySrd);
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -4313,7 +4291,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
myObservationDao.create(obs, mySrd);
|
myObservationDao.create(obs, mySrd);
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -4326,7 +4304,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
myObservationDao.create(obs, mySrd);
|
myObservationDao.create(obs, mySrd);
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -4339,24 +4317,24 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
myObservationDao.create(obs, mySrd);
|
myObservationDao.create(obs, mySrd);
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
// > 1m
|
// > 1m
|
||||||
String uri = myServerBase + "/Observation?code-value-quantity=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7$gt1|http://unitsofmeasure.org|m");
|
String uri = myServerBase + "/Observation?code-value-quantity=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7$gt1|http://unitsofmeasure.org|m");
|
||||||
ourLog.info("uri = " + uri);
|
ourLog.info("uri = {}", uri);
|
||||||
List<String> ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
List<String> ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
||||||
assertThat(ids).hasSize(3);
|
assertThat(ids).hasSize(3);
|
||||||
|
|
||||||
//>= 100cm
|
//>= 100cm
|
||||||
uri = myServerBase + "/Observation?code-value-quantity=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7$gt100|http://unitsofmeasure.org|cm");
|
uri = myServerBase + "/Observation?code-value-quantity=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7$gt100|http://unitsofmeasure.org|cm");
|
||||||
ourLog.info("uri = " + uri);
|
ourLog.info("uri = {}", uri);
|
||||||
ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
||||||
assertThat(ids).hasSize(3);
|
assertThat(ids).hasSize(3);
|
||||||
|
|
||||||
//>= 10dm
|
//>= 10dm
|
||||||
uri = myServerBase + "/Observation?code-value-quantity=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7$gt10|http://unitsofmeasure.org|dm");
|
uri = myServerBase + "/Observation?code-value-quantity=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7$gt10|http://unitsofmeasure.org|dm");
|
||||||
ourLog.info("uri = " + uri);
|
ourLog.info("uri = {}", uri);
|
||||||
ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
||||||
assertThat(ids).hasSize(3);
|
assertThat(ids).hasSize(3);
|
||||||
}
|
}
|
||||||
|
@ -4381,7 +4359,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
myObservationDao.create(obs, mySrd);
|
myObservationDao.create(obs, mySrd);
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -4392,7 +4370,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
myObservationDao.create(obs, mySrd);
|
myObservationDao.create(obs, mySrd);
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -4403,7 +4381,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
myObservationDao.create(obs, mySrd);
|
myObservationDao.create(obs, mySrd);
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -4414,7 +4392,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
myObservationDao.create(obs, mySrd);
|
myObservationDao.create(obs, mySrd);
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
String uri;
|
String uri;
|
||||||
|
@ -4451,7 +4429,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
myObservationDao.create(obs, mySrd);
|
myObservationDao.create(obs, mySrd);
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -4462,7 +4440,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
myObservationDao.create(obs, mySrd);
|
myObservationDao.create(obs, mySrd);
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -4474,7 +4452,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
myObservationDao.create(obs, mySrd);
|
myObservationDao.create(obs, mySrd);
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
myCaptureQueriesListener.clear();
|
myCaptureQueriesListener.clear();
|
||||||
|
@ -4490,8 +4468,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
//-- check use normalized quantity table to search
|
//-- check use normalized quantity table to search
|
||||||
String searchSql = myCaptureQueriesListener.getSelectQueries().get(0).getSql(true, true);
|
String searchSql = myCaptureQueriesListener.getSelectQueries().get(0).getSql(true, true);
|
||||||
assertThat(searchSql).doesNotContain("HFJ_SPIDX_QUANTITY t0");
|
assertThat(searchSql).doesNotContain("HFJ_SPIDX_QUANTITY t0").contains("HFJ_SPIDX_QUANTITY_NRML");
|
||||||
assertThat(searchSql).contains("HFJ_SPIDX_QUANTITY_NRML");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -5044,7 +5021,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
oid1 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
oid1 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -5056,7 +5033,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
oid2 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
oid2 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -5068,7 +5045,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
oid3 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
oid3 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -5080,7 +5057,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
oid4 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
oid4 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
String uri = myServerBase + "/Observation?_sort=code-value-quantity";
|
String uri = myServerBase + "/Observation?_sort=code-value-quantity";
|
||||||
|
@ -5092,7 +5069,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
found = myFhirContext.newXmlParser().parseResource(Bundle.class, output);
|
found = myFhirContext.newXmlParser().parseResource(Bundle.class, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
ourLog.debug("Bundle: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(found));
|
ourLog.debug("Bundle: {}\n", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(found));
|
||||||
|
|
||||||
List<IIdType> list = toUnqualifiedVersionlessIds(found);
|
List<IIdType> list = toUnqualifiedVersionlessIds(found);
|
||||||
assertThat(found.getEntry()).hasSize(4);
|
assertThat(found.getEntry()).hasSize(4);
|
||||||
|
@ -5129,7 +5106,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
oid1 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
oid1 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -5145,7 +5122,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
oid2 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
oid2 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -5161,7 +5138,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
oid3 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
oid3 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -5176,7 +5153,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
comp.setValue(new Quantity().setValue(250));
|
comp.setValue(new Quantity().setValue(250));
|
||||||
oid4 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
oid4 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
String uri = myServerBase + "/Observation?_sort=combo-code-value-quantity";
|
String uri = myServerBase + "/Observation?_sort=combo-code-value-quantity";
|
||||||
|
@ -5188,7 +5165,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
found = myFhirContext.newXmlParser().parseResource(Bundle.class, output);
|
found = myFhirContext.newXmlParser().parseResource(Bundle.class, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
ourLog.debug("Bundle: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(found));
|
ourLog.debug("Bundle: {}\n", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(found));
|
||||||
|
|
||||||
List<IIdType> list = toUnqualifiedVersionlessIds(found);
|
List<IIdType> list = toUnqualifiedVersionlessIds(found);
|
||||||
assertThat(found.getEntry()).hasSize(4);
|
assertThat(found.getEntry()).hasSize(4);
|
||||||
|
@ -5264,9 +5241,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
List<IIdType> list = toUnqualifiedVersionlessIds(found);
|
List<IIdType> list = toUnqualifiedVersionlessIds(found);
|
||||||
ourLog.info(methodName + " found: " + list.toString() + " - Wanted " + orgMissing + " but not " + orgNotMissing);
|
ourLog.info(methodName + " found: " + list.toString() + " - Wanted " + orgMissing + " but not " + orgNotMissing);
|
||||||
assertThat(list).doesNotContain(orgNotMissing);
|
assertThat(list).doesNotContain(orgNotMissing).doesNotContain(deletedIdMissingTrue).contains(orgMissing);
|
||||||
assertThat(list).doesNotContain(deletedIdMissingTrue);
|
|
||||||
assertThat(list).contains(orgMissing);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -5927,7 +5902,6 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
Date before = new Date();
|
Date before = new Date();
|
||||||
Thread.sleep(100);
|
|
||||||
|
|
||||||
pt = new Patient();
|
pt = new Patient();
|
||||||
pt.setId(id.getIdPart());
|
pt.setId(id.getIdPart());
|
||||||
|
@ -6450,7 +6424,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
cc.addCoding().setCode("2345-7").setSystem("http://loinc.org");
|
cc.addCoding().setCode("2345-7").setSystem("http://loinc.org");
|
||||||
obs.setValue(new Quantity().setValueElement(new DecimalType(125.12)).setUnit("CM").setSystem(UcumServiceUtil.UCUM_CODESYSTEM_URL).setCode("cm"));
|
obs.setValue(new Quantity().setValueElement(new DecimalType(125.12)).setUnit("CM").setSystem(UcumServiceUtil.UCUM_CODESYSTEM_URL).setCode("cm"));
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
|
|
||||||
IIdType opid1 = myObservationDao.create(obs, mySrd).getId();
|
IIdType opid1 = myObservationDao.create(obs, mySrd).getId();
|
||||||
|
|
||||||
|
@ -6463,7 +6437,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
cc.addCoding().setCode("2345-7").setSystem("http://loinc.org");
|
cc.addCoding().setCode("2345-7").setSystem("http://loinc.org");
|
||||||
obs.setValue(new Quantity().setValueElement(new DecimalType(24.12)).setUnit("CM").setSystem(UcumServiceUtil.UCUM_CODESYSTEM_URL).setCode("cm"));
|
obs.setValue(new Quantity().setValueElement(new DecimalType(24.12)).setUnit("CM").setSystem(UcumServiceUtil.UCUM_CODESYSTEM_URL).setCode("cm"));
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
|
|
||||||
myObservationDao.update(obs, mySrd);
|
myObservationDao.update(obs, mySrd);
|
||||||
}
|
}
|
||||||
|
@ -6479,7 +6453,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
myObservationDao.create(obs, mySrd);
|
myObservationDao.create(obs, mySrd);
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -6492,7 +6466,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
myObservationDao.create(obs, mySrd);
|
myObservationDao.create(obs, mySrd);
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -6505,25 +6479,25 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
myObservationDao.create(obs, mySrd);
|
myObservationDao.create(obs, mySrd);
|
||||||
|
|
||||||
ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
ourLog.debug("Observation: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||||
}
|
}
|
||||||
|
|
||||||
// > 1m
|
// > 1m
|
||||||
String uri = myServerBase + "/Observation?code-value-quantity=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7$gt1|http://unitsofmeasure.org|m");
|
String uri = myServerBase + "/Observation?code-value-quantity=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7$gt1|http://unitsofmeasure.org|m");
|
||||||
ourLog.info("uri = " + uri);
|
ourLog.info("uri = {}", uri);
|
||||||
List<String> ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
List<String> ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
||||||
assertThat(ids).hasSize(2);
|
assertThat(ids).hasSize(2);
|
||||||
|
|
||||||
|
|
||||||
//>= 100cm
|
//>= 100cm
|
||||||
uri = myServerBase + "/Observation?code-value-quantity=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7$gt100|http://unitsofmeasure.org|cm");
|
uri = myServerBase + "/Observation?code-value-quantity=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7$gt100|http://unitsofmeasure.org|cm");
|
||||||
ourLog.info("uri = " + uri);
|
ourLog.info("uri = {}", uri);
|
||||||
ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
||||||
assertThat(ids).hasSize(2);
|
assertThat(ids).hasSize(2);
|
||||||
|
|
||||||
//>= 10dm
|
//>= 10dm
|
||||||
uri = myServerBase + "/Observation?code-value-quantity=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7$gt10|http://unitsofmeasure.org|dm");
|
uri = myServerBase + "/Observation?code-value-quantity=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7$gt10|http://unitsofmeasure.org|dm");
|
||||||
ourLog.info("uri = " + uri);
|
ourLog.info("uri = {}", uri);
|
||||||
ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
||||||
assertThat(ids).hasSize(2);
|
assertThat(ids).hasSize(2);
|
||||||
}
|
}
|
||||||
|
@ -6540,7 +6514,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
patient.setBirthDateElement(new DateType("2073"));
|
patient.setBirthDateElement(new DateType("2073"));
|
||||||
pid0 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
pid0 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
ourLog.debug("Patient: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient));
|
ourLog.debug("Patient: {}\n", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient));
|
||||||
|
|
||||||
ourLog.info("pid0 " + pid0);
|
ourLog.info("pid0 " + pid0);
|
||||||
}
|
}
|
||||||
|
@ -6553,7 +6527,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
ourLog.info(resp);
|
ourLog.info(resp);
|
||||||
Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp);
|
Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp);
|
||||||
ourLog.debug("Patient: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));
|
ourLog.debug("Patient: {}\n", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));
|
||||||
}
|
}
|
||||||
|
|
||||||
uri = myServerBase + "/Patient?_total=accurate&birthdate=gt2072-01-01";
|
uri = myServerBase + "/Patient?_total=accurate&birthdate=gt2072-01-01";
|
||||||
|
@ -6564,7 +6538,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
ourLog.info(resp);
|
ourLog.info(resp);
|
||||||
Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp);
|
Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp);
|
||||||
ourLog.debug("Patient: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));
|
ourLog.debug("Patient: {}\n", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6995,9 +6969,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
&& theInput.IsEnforceRefOnType
|
&& theInput.IsEnforceRefOnType
|
||||||
&& theInput.IsEnforceRefOnWrite).isFalse();
|
&& theInput.IsEnforceRefOnWrite).isFalse();
|
||||||
} catch (InvalidRequestException ex) {
|
} catch (InvalidRequestException ex) {
|
||||||
assertThat(ex.getMessage().contains(
|
assertThat(ex.getMessage()).as(ex.getMessage()).contains("Invalid resource reference");
|
||||||
"Invalid resource reference"
|
|
||||||
)).as(ex.getMessage()).isTrue();
|
|
||||||
} finally {
|
} finally {
|
||||||
myStorageSettings.setEnforceReferentialIntegrityOnWrite(isEnforceRefOnWrite);
|
myStorageSettings.setEnforceReferentialIntegrityOnWrite(isEnforceRefOnWrite);
|
||||||
myStorageSettings.setEnforceReferenceTargetTypes(isEnforceRefTargetTypes);
|
myStorageSettings.setEnforceReferenceTargetTypes(isEnforceRefTargetTypes);
|
||||||
|
@ -7331,9 +7303,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
patient.setBirthDate(cal.getTime());
|
patient.setBirthDate(cal.getTime());
|
||||||
}
|
}
|
||||||
return patient;
|
return patient;
|
||||||
}, (isMissing) -> {
|
}, (isMissing) -> doSearch(Patient.class, Patient.BIRTHDATE.isMissing(isMissing)));
|
||||||
return doSearch(Patient.class, Patient.BIRTHDATE.isMissing(isMissing));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
|
@ -7346,9 +7316,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
patient.setGender(AdministrativeGender.FEMALE);
|
patient.setGender(AdministrativeGender.FEMALE);
|
||||||
}
|
}
|
||||||
return patient;
|
return patient;
|
||||||
}, isMissing -> {
|
}, isMissing -> doSearch(Patient.class, Patient.GENDER.isMissing(isMissing)));
|
||||||
return doSearch(Patient.class, Patient.GENDER.isMissing(isMissing));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
|
@ -7364,9 +7332,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
patient.setGeneralPractitioner(Collections.singletonList(new Reference(practitionerId)));
|
patient.setGeneralPractitioner(Collections.singletonList(new Reference(practitionerId)));
|
||||||
}
|
}
|
||||||
return patient;
|
return patient;
|
||||||
}, isMissing -> {
|
}, isMissing -> doSearch(Patient.class, Patient.GENERAL_PRACTITIONER.isMissing(isMissing)));
|
||||||
return doSearch(Patient.class, Patient.GENERAL_PRACTITIONER.isMissing(isMissing));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
|
@ -7409,9 +7375,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
sp.setUrl("http://example.com");
|
sp.setUrl("http://example.com");
|
||||||
}
|
}
|
||||||
return sp;
|
return sp;
|
||||||
}, isMissing -> {
|
}, isMissing -> doSearch(SearchParameter.class, SearchParameter.URL.isMissing(isMissing)));
|
||||||
return doSearch(SearchParameter.class, SearchParameter.URL.isMissing(isMissing));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
|
@ -7424,9 +7388,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
obs.setValue(new Quantity(3));
|
obs.setValue(new Quantity(3));
|
||||||
}
|
}
|
||||||
return obs;
|
return obs;
|
||||||
}, isMissing -> {
|
}, isMissing -> doSearch(Observation.class, Observation.VALUE_QUANTITY.isMissing(isMissing)));
|
||||||
return doSearch(Observation.class, Observation.VALUE_QUANTITY.isMissing(isMissing));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
|
@ -7457,7 +7419,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
Y doTask(X theInput);
|
Y doTask(X theInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class MissingSearchTestParameters {
|
public static class MissingSearchTestParameters {
|
||||||
/**
|
/**
|
||||||
* The setting for IndexMissingFields
|
* The setting for IndexMissingFields
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -79,25 +79,11 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.simplejavamail</groupId>
|
<groupId>org.simplejavamail</groupId>
|
||||||
<artifactId>simple-java-mail</artifactId>
|
<artifactId>simple-java-mail</artifactId>
|
||||||
<!-- Excluded in favor of jakarta.activation:jakarta.activation-api -->
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.sun.activation</groupId>
|
|
||||||
<artifactId>jakarta.activation</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.icegreen</groupId>
|
<groupId>com.icegreen</groupId>
|
||||||
<artifactId>greenmail</artifactId>
|
<artifactId>greenmail</artifactId>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<!-- Excluded in favor of jakarta.activation:jakarta.activation-api -->
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.sun.activation</groupId>
|
|
||||||
<artifactId>jakarta.activation</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,9 @@ package ca.uhn.fhir.rest.server.mail;
|
||||||
|
|
||||||
import jakarta.annotation.Nonnull;
|
import jakarta.annotation.Nonnull;
|
||||||
import org.simplejavamail.api.email.Email;
|
import org.simplejavamail.api.email.Email;
|
||||||
import org.simplejavamail.api.mailer.AsyncResponse;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public interface IMailSvc {
|
public interface IMailSvc {
|
||||||
void sendMail(@Nonnull List<Email> theEmails);
|
void sendMail(@Nonnull List<Email> theEmails);
|
||||||
|
@ -31,7 +31,5 @@ public interface IMailSvc {
|
||||||
void sendMail(@Nonnull Email theEmail);
|
void sendMail(@Nonnull Email theEmail);
|
||||||
|
|
||||||
void sendMail(
|
void sendMail(
|
||||||
@Nonnull Email theEmail,
|
@Nonnull Email theEmail, @Nonnull Runnable theOnSuccess, @Nonnull Consumer<Throwable> theErrorHandler);
|
||||||
@Nonnull Runnable theOnSuccess,
|
|
||||||
@Nonnull AsyncResponse.ExceptionConsumer theErrorHandler);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,9 @@
|
||||||
package ca.uhn.fhir.rest.server.mail;
|
package ca.uhn.fhir.rest.server.mail;
|
||||||
|
|
||||||
import jakarta.annotation.Nonnull;
|
import jakarta.annotation.Nonnull;
|
||||||
import org.apache.commons.lang3.Validate;
|
|
||||||
import org.simplejavamail.MailException;
|
import org.simplejavamail.MailException;
|
||||||
import org.simplejavamail.api.email.Email;
|
import org.simplejavamail.api.email.Email;
|
||||||
import org.simplejavamail.api.email.Recipient;
|
import org.simplejavamail.api.email.Recipient;
|
||||||
import org.simplejavamail.api.mailer.AsyncResponse;
|
|
||||||
import org.simplejavamail.api.mailer.AsyncResponse.ExceptionConsumer;
|
|
||||||
import org.simplejavamail.api.mailer.Mailer;
|
import org.simplejavamail.api.mailer.Mailer;
|
||||||
import org.simplejavamail.api.mailer.config.TransportStrategy;
|
import org.simplejavamail.api.mailer.config.TransportStrategy;
|
||||||
import org.simplejavamail.mailer.MailerBuilder;
|
import org.simplejavamail.mailer.MailerBuilder;
|
||||||
|
@ -33,6 +30,8 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MailSvc implements IMailSvc {
|
public class MailSvc implements IMailSvc {
|
||||||
|
@ -42,14 +41,14 @@ public class MailSvc implements IMailSvc {
|
||||||
private final Mailer myMailer;
|
private final Mailer myMailer;
|
||||||
|
|
||||||
public MailSvc(@Nonnull MailConfig theMailConfig) {
|
public MailSvc(@Nonnull MailConfig theMailConfig) {
|
||||||
Validate.notNull(theMailConfig);
|
Objects.requireNonNull(theMailConfig);
|
||||||
myMailConfig = theMailConfig;
|
myMailConfig = theMailConfig;
|
||||||
myMailer = makeMailer(myMailConfig);
|
myMailer = makeMailer(myMailConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMail(@Nonnull List<Email> theEmails) {
|
public void sendMail(@Nonnull List<Email> theEmails) {
|
||||||
Validate.notNull(theEmails);
|
Objects.requireNonNull(theEmails);
|
||||||
theEmails.forEach(theEmail -> send(theEmail, new OnSuccess(theEmail), new ErrorHandler(theEmail)));
|
theEmails.forEach(theEmail -> send(theEmail, new OnSuccess(theEmail), new ErrorHandler(theEmail)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,21 +59,23 @@ public class MailSvc implements IMailSvc {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMail(
|
public void sendMail(
|
||||||
@Nonnull Email theEmail, @Nonnull Runnable theOnSuccess, @Nonnull ExceptionConsumer theErrorHandler) {
|
@Nonnull Email theEmail, @Nonnull Runnable theOnSuccess, @Nonnull Consumer<Throwable> theErrorHandler) {
|
||||||
send(theEmail, theOnSuccess, theErrorHandler);
|
send(theEmail, theOnSuccess, theErrorHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void send(
|
private void send(
|
||||||
@Nonnull Email theEmail, @Nonnull Runnable theOnSuccess, @Nonnull ExceptionConsumer theErrorHandler) {
|
@Nonnull Email theEmail, @Nonnull Runnable theOnSuccess, @Nonnull Consumer<Throwable> theErrorHandler) {
|
||||||
Validate.notNull(theEmail);
|
Objects.requireNonNull(theEmail);
|
||||||
Validate.notNull(theOnSuccess);
|
Objects.requireNonNull(theOnSuccess);
|
||||||
Validate.notNull(theErrorHandler);
|
Objects.requireNonNull(theErrorHandler);
|
||||||
try {
|
try {
|
||||||
final AsyncResponse asyncResponse = myMailer.sendMail(theEmail, true);
|
myMailer.sendMail(theEmail, true).whenComplete((result, ex) -> {
|
||||||
if (asyncResponse != null) {
|
if (ex != null) {
|
||||||
asyncResponse.onSuccess(theOnSuccess);
|
theErrorHandler.accept(ex);
|
||||||
asyncResponse.onException(theErrorHandler);
|
} else {
|
||||||
|
theOnSuccess.run();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
} catch (MailException e) {
|
} catch (MailException e) {
|
||||||
theErrorHandler.accept(e);
|
theErrorHandler.accept(e);
|
||||||
}
|
}
|
||||||
|
@ -117,7 +118,7 @@ public class MailSvc implements IMailSvc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ErrorHandler implements ExceptionConsumer {
|
private class ErrorHandler implements Consumer<Throwable> {
|
||||||
private final Email myEmail;
|
private final Email myEmail;
|
||||||
|
|
||||||
private ErrorHandler(@Nonnull Email theEmail) {
|
private ErrorHandler(@Nonnull Email theEmail) {
|
||||||
|
@ -125,7 +126,7 @@ public class MailSvc implements IMailSvc {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void accept(Exception t) {
|
public void accept(Throwable t) {
|
||||||
ourLog.error("Email not sent" + makeMessage(myEmail), t);
|
ourLog.error("Email not sent" + makeMessage(myEmail), t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.icegreen.greenmail.junit5.GreenMailExtension;
|
||||||
import com.icegreen.greenmail.util.GreenMailUtil;
|
import com.icegreen.greenmail.util.GreenMailUtil;
|
||||||
import com.icegreen.greenmail.util.ServerSetupTest;
|
import com.icegreen.greenmail.util.ServerSetupTest;
|
||||||
import jakarta.annotation.Nonnull;
|
import jakarta.annotation.Nonnull;
|
||||||
|
import jakarta.mail.internet.MimeMessage;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
|
@ -11,7 +12,6 @@ import org.simplejavamail.MailException;
|
||||||
import org.simplejavamail.api.email.Email;
|
import org.simplejavamail.api.email.Email;
|
||||||
import org.simplejavamail.email.EmailBuilder;
|
import org.simplejavamail.email.EmailBuilder;
|
||||||
|
|
||||||
import javax.mail.internet.MimeMessage;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -86,13 +86,14 @@ public class MailSvcIT {
|
||||||
@Test
|
@Test
|
||||||
public void testSendMailWithInvalidToAddressExpectErrorHandler() {
|
public void testSendMailWithInvalidToAddressExpectErrorHandler() {
|
||||||
// setup
|
// setup
|
||||||
final Email email = withEmail("xyz");
|
String invalidEmailAdress = "xyz";
|
||||||
|
final Email email = withEmail(invalidEmailAdress);
|
||||||
// execute
|
// execute
|
||||||
fixture.sendMail(email,
|
fixture.sendMail(email,
|
||||||
() -> fail("Should not execute on Success"),
|
() -> fail("Should not execute on Success"),
|
||||||
(e) -> {
|
(e) -> {
|
||||||
assertTrue(e instanceof MailException);
|
assertTrue(e instanceof MailException);
|
||||||
assertEquals("Invalid TO address: " + email, e.getMessage());
|
assertEquals("Invalid TO address: " + invalidEmailAdress, e.getMessage());
|
||||||
});
|
});
|
||||||
// validate
|
// validate
|
||||||
assertTrue(ourGreenMail.waitForIncomingEmail(1000, 0));
|
assertTrue(ourGreenMail.waitForIncomingEmail(1000, 0));
|
||||||
|
|
34
pom.xml
34
pom.xml
|
@ -869,6 +869,7 @@
|
||||||
<developer>
|
<developer>
|
||||||
<id>delopst</id>
|
<id>delopst</id>
|
||||||
<name>Primož Delopst</name>
|
<name>Primož Delopst</name>
|
||||||
|
<organization>Better</organization>
|
||||||
</developer>
|
</developer>
|
||||||
<developer>
|
<developer>
|
||||||
<id>Zach Smith</id>
|
<id>Zach Smith</id>
|
||||||
|
@ -1160,27 +1161,38 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.simplejavamail</groupId>
|
<groupId>org.simplejavamail</groupId>
|
||||||
<artifactId>simple-java-mail</artifactId>
|
<artifactId>simple-java-mail</artifactId>
|
||||||
<version>6.6.1</version>
|
<version>8.11.2</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>com.sun.activation</groupId>
|
<groupId>com.github.bbottema</groupId>
|
||||||
<artifactId>jakarta.activation-api</artifactId>
|
<artifactId>jetbrains-runtime-annotations</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>com.sun.activation</groupId>
|
<groupId>jakarta.mail</groupId>
|
||||||
<artifactId>jakarta.activation</artifactId>
|
<artifactId>jakarta.mail-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.mail</groupId>
|
||||||
|
<artifactId>jakarta.mail-api</artifactId>
|
||||||
|
<version>2.1.3</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.icegreen</groupId>
|
||||||
|
<artifactId>greenmail</artifactId>
|
||||||
|
<version>2.1.0-rc-1</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>jakarta.mail</groupId>
|
||||||
|
<artifactId>jakarta.mail-api</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.icegreen</groupId>
|
|
||||||
<artifactId>greenmail</artifactId>
|
|
||||||
<version>1.6.4</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.icegreen</groupId>
|
<groupId>com.icegreen</groupId>
|
||||||
<artifactId>greenmail-junit5</artifactId>
|
<artifactId>greenmail-junit5</artifactId>
|
||||||
<version>1.6.4</version>
|
<version>2.1.0-rc-1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- mail end -->
|
<!-- mail end -->
|
||||||
|
|
Loading…
Reference in New Issue