Slightly more portable solution for paging
This commit is contained in:
parent
a770d577cb
commit
61260dd1b1
|
@ -27,6 +27,7 @@ import ca.uhn.fhir.jpa.entity.MdmLink;
|
||||||
import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum;
|
import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum;
|
||||||
import ca.uhn.fhir.mdm.api.MdmMatchOutcome;
|
import ca.uhn.fhir.mdm.api.MdmMatchOutcome;
|
||||||
import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
|
import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
|
||||||
|
import ca.uhn.fhir.mdm.api.paging.MdmPageRequest;
|
||||||
import ca.uhn.fhir.mdm.log.Logs;
|
import ca.uhn.fhir.mdm.log.Logs;
|
||||||
import ca.uhn.fhir.mdm.model.MdmTransactionContext;
|
import ca.uhn.fhir.mdm.model.MdmTransactionContext;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
@ -34,8 +35,6 @@ import org.slf4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Example;
|
import org.springframework.data.domain.Example;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@ -289,9 +288,8 @@ public class MdmLinkDaoSvc {
|
||||||
* @param theExampleLink The MDM link containing the data we would like to search for.
|
* @param theExampleLink The MDM link containing the data we would like to search for.
|
||||||
* @return a list of {@link MdmLink} entities which match the example.
|
* @return a list of {@link MdmLink} entities which match the example.
|
||||||
*/
|
*/
|
||||||
public Page<MdmLink> findMdmLinkByExample(Example<MdmLink> theExampleLink, int theOffset, int theCount) {
|
public Page<MdmLink> findMdmLinkByExample(Example<MdmLink> theExampleLink, MdmPageRequest thePageRequest) {
|
||||||
PageRequest of = PageRequest.of(theOffset / theCount, theCount);
|
return myMdmLinkDao.findAll(theExampleLink, thePageRequest.toPageRequest());
|
||||||
return myMdmLinkDao.findAll(theExampleLink, of);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,6 +27,7 @@ import ca.uhn.fhir.mdm.api.IMdmLinkUpdaterSvc;
|
||||||
import ca.uhn.fhir.mdm.api.MdmLinkJson;
|
import ca.uhn.fhir.mdm.api.MdmLinkJson;
|
||||||
import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum;
|
import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum;
|
||||||
import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
|
import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
|
||||||
|
import ca.uhn.fhir.mdm.api.paging.MdmPageRequest;
|
||||||
import ca.uhn.fhir.mdm.model.MdmTransactionContext;
|
import ca.uhn.fhir.mdm.model.MdmTransactionContext;
|
||||||
import ca.uhn.fhir.mdm.provider.MdmControllerHelper;
|
import ca.uhn.fhir.mdm.provider.MdmControllerHelper;
|
||||||
import ca.uhn.fhir.mdm.provider.MdmControllerUtil;
|
import ca.uhn.fhir.mdm.provider.MdmControllerUtil;
|
||||||
|
@ -34,10 +35,10 @@ import ca.uhn.fhir.rest.server.provider.ProviderConstants;
|
||||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class acts as a layer between MdmProviders and MDM services to support a REST API that's not a FHIR Operation API.
|
* This class acts as a layer between MdmProviders and MDM services to support a REST API that's not a FHIR Operation API.
|
||||||
|
@ -66,17 +67,17 @@ public class MdmControllerSvcImpl implements IMdmControllerSvc {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<MdmLinkJson> queryLinks(@Nullable String theGoldenResourceId, @Nullable String theSourceResourceId, @Nullable String theMatchResult, @Nullable String theLinkSource, MdmTransactionContext theMdmTransactionContext, int theOffset, int theCount) {
|
public Page<MdmLinkJson> queryLinks(@Nullable String theGoldenResourceId, @Nullable String theSourceResourceId, @Nullable String theMatchResult, @Nullable String theLinkSource, MdmTransactionContext theMdmTransactionContext, MdmPageRequest thePageRequest) {
|
||||||
IIdType goldenResourceId = MdmControllerUtil.extractGoldenResourceIdDtOrNull(ProviderConstants.MDM_QUERY_LINKS_GOLDEN_RESOURCE_ID, theGoldenResourceId);
|
IIdType goldenResourceId = MdmControllerUtil.extractGoldenResourceIdDtOrNull(ProviderConstants.MDM_QUERY_LINKS_GOLDEN_RESOURCE_ID, theGoldenResourceId);
|
||||||
IIdType sourceId = MdmControllerUtil.extractSourceIdDtOrNull(ProviderConstants.MDM_QUERY_LINKS_RESOURCE_ID, theSourceResourceId);
|
IIdType sourceId = MdmControllerUtil.extractSourceIdDtOrNull(ProviderConstants.MDM_QUERY_LINKS_RESOURCE_ID, theSourceResourceId);
|
||||||
MdmMatchResultEnum matchResult = MdmControllerUtil.extractMatchResultOrNull(theMatchResult);
|
MdmMatchResultEnum matchResult = MdmControllerUtil.extractMatchResultOrNull(theMatchResult);
|
||||||
MdmLinkSourceEnum linkSource = MdmControllerUtil.extractLinkSourceOrNull(theLinkSource);
|
MdmLinkSourceEnum linkSource = MdmControllerUtil.extractLinkSourceOrNull(theLinkSource);
|
||||||
return myMdmLinkQuerySvc.queryLinks(goldenResourceId, sourceId, matchResult, linkSource, theMdmTransactionContext, theOffset, theCount);
|
return myMdmLinkQuerySvc.queryLinks(goldenResourceId, sourceId, matchResult, linkSource, theMdmTransactionContext, thePageRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<MdmLinkJson> getDuplicateGoldenResources(MdmTransactionContext theMdmTransactionContext, int theOffset, int theCount) {
|
public Page<MdmLinkJson> getDuplicateGoldenResources(MdmTransactionContext theMdmTransactionContext, MdmPageRequest thePageRequest) {
|
||||||
return myMdmLinkQuerySvc.getDuplicateGoldenResources(theMdmTransactionContext, theOffset, theCount);
|
return myMdmLinkQuerySvc.getDuplicateGoldenResources(theMdmTransactionContext, thePageRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -24,6 +24,7 @@ import ca.uhn.fhir.mdm.api.MdmLinkJson;
|
||||||
import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum;
|
import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum;
|
||||||
import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
|
import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
|
||||||
import ca.uhn.fhir.mdm.api.IMdmLinkQuerySvc;
|
import ca.uhn.fhir.mdm.api.IMdmLinkQuerySvc;
|
||||||
|
import ca.uhn.fhir.mdm.api.paging.MdmPageRequest;
|
||||||
import ca.uhn.fhir.mdm.model.MdmTransactionContext;
|
import ca.uhn.fhir.mdm.model.MdmTransactionContext;
|
||||||
import ca.uhn.fhir.jpa.dao.index.IdHelperService;
|
import ca.uhn.fhir.jpa.dao.index.IdHelperService;
|
||||||
import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc;
|
import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc;
|
||||||
|
@ -35,8 +36,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Example;
|
import org.springframework.data.domain.Example;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public class MdmLinkQuerySvcImpl implements IMdmLinkQuerySvc {
|
public class MdmLinkQuerySvcImpl implements IMdmLinkQuerySvc {
|
||||||
|
|
||||||
private static final Logger ourLog = LoggerFactory.getLogger(MdmLinkQuerySvcImpl.class);
|
private static final Logger ourLog = LoggerFactory.getLogger(MdmLinkQuerySvcImpl.class);
|
||||||
|
@ -47,16 +46,19 @@ public class MdmLinkQuerySvcImpl implements IMdmLinkQuerySvc {
|
||||||
MdmLinkDaoSvc myMdmLinkDaoSvc;
|
MdmLinkDaoSvc myMdmLinkDaoSvc;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<MdmLinkJson> queryLinks(IIdType theGoldenResourceId, IIdType theSourceResourceId, MdmMatchResultEnum theMatchResult, MdmLinkSourceEnum theLinkSource, MdmTransactionContext theMdmContext, int theOffset, int theCount) {
|
public Page<MdmLinkJson> queryLinks(IIdType theGoldenResourceId, IIdType theSourceResourceId, MdmMatchResultEnum theMatchResult, MdmLinkSourceEnum theLinkSource, MdmTransactionContext theMdmContext, MdmPageRequest thePageRequest) {
|
||||||
Example<MdmLink> exampleLink = exampleLinkFromParameters(theGoldenResourceId, theSourceResourceId, theMatchResult, theLinkSource);
|
Example<MdmLink> exampleLink = exampleLinkFromParameters(theGoldenResourceId, theSourceResourceId, theMatchResult, theLinkSource);
|
||||||
Page<MdmLink> mdmLinkByExample = myMdmLinkDaoSvc.findMdmLinkByExample(exampleLink, theOffset, theCount);
|
Page<MdmLink> mdmLinkByExample = myMdmLinkDaoSvc.findMdmLinkByExample(exampleLink, thePageRequest);
|
||||||
return mdmLinkByExample.stream().map(this::toJson);
|
Page<MdmLinkJson> map = mdmLinkByExample.map(this::toJson);
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<MdmLinkJson> getDuplicateGoldenResources(MdmTransactionContext theMdmContext, int theOffset, int theCount) {
|
public Page<MdmLinkJson> getDuplicateGoldenResources(MdmTransactionContext theMdmContext, MdmPageRequest thePageRequest) {
|
||||||
Example<MdmLink> exampleLink = exampleLinkFromParameters(null, null, MdmMatchResultEnum.POSSIBLE_DUPLICATE, null);
|
Example<MdmLink> exampleLink = exampleLinkFromParameters(null, null, MdmMatchResultEnum.POSSIBLE_DUPLICATE, null);
|
||||||
return myMdmLinkDaoSvc.findMdmLinkByExample(exampleLink, theOffset, theCount).stream().map(this::toJson);
|
Page<MdmLink> mdmLinkPage = myMdmLinkDaoSvc.findMdmLinkByExample(exampleLink, thePageRequest);
|
||||||
|
Page<MdmLinkJson> map = mdmLinkPage.map(this::toJson);
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MdmLinkJson toJson(MdmLink theLink) {
|
private MdmLinkJson toJson(MdmLink theLink) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import ca.uhn.fhir.mdm.api.IMdmMatchFinderSvc;
|
||||||
import ca.uhn.fhir.mdm.api.IMdmSubmitSvc;
|
import ca.uhn.fhir.mdm.api.IMdmSubmitSvc;
|
||||||
import ca.uhn.fhir.mdm.provider.MdmProviderDstu3Plus;
|
import ca.uhn.fhir.mdm.provider.MdmProviderDstu3Plus;
|
||||||
import ca.uhn.fhir.mdm.rules.config.MdmSettings;
|
import ca.uhn.fhir.mdm.rules.config.MdmSettings;
|
||||||
|
import ca.uhn.fhir.rest.server.IRestfulServerDefaults;
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
@ -29,6 +30,8 @@ public abstract class BaseProviderR4Test extends BaseMdmR4Test {
|
||||||
private IMdmSubmitSvc myMdmSubmitSvc;
|
private IMdmSubmitSvc myMdmSubmitSvc;
|
||||||
@Autowired
|
@Autowired
|
||||||
private MdmSettings myMdmSettings;
|
private MdmSettings myMdmSettings;
|
||||||
|
@Autowired
|
||||||
|
private IRestfulServerDefaults myRestfulServerDefaults;
|
||||||
|
|
||||||
private String defaultScript;
|
private String defaultScript;
|
||||||
|
|
||||||
|
@ -42,7 +45,7 @@ public abstract class BaseProviderR4Test extends BaseMdmR4Test {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void before() {
|
public void before() {
|
||||||
myMdmProvider = new MdmProviderDstu3Plus(myFhirContext, myMdmControllerSvc, myMdmMatchFinderSvc, myMdmExpungeSvc, myMdmSubmitSvc);
|
myMdmProvider = new MdmProviderDstu3Plus(myFhirContext, myMdmControllerSvc, myMdmMatchFinderSvc, myMdmExpungeSvc, myMdmSubmitSvc, myRestfulServerDefaults);
|
||||||
defaultScript = myMdmSettings.getScriptText();
|
defaultScript = myMdmSettings.getScriptText();
|
||||||
}
|
}
|
||||||
@AfterEach
|
@AfterEach
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class MdmProviderQueryLinkR4Test extends BaseLinkR4Test {
|
||||||
ourLog.warn("Search at offset {} took {}ms",offset, sw.getMillisAndRestart());
|
ourLog.warn("Search at offset {} took {}ms",offset, sw.getMillisAndRestart());
|
||||||
ourLog.warn("Found source resource IDs: {}", sourceResourceIds);
|
ourLog.warn("Found source resource IDs: {}", sourceResourceIds);
|
||||||
offset += count;
|
offset += count;
|
||||||
assertThat(parameter.size(), is(lessThanOrEqualTo(2)));
|
assertThat(parameter.size(), is(lessThanOrEqualTo(3)));
|
||||||
|
|
||||||
//We have stopped finding patients.
|
//We have stopped finding patients.
|
||||||
if (StringUtils.isEmpty(sourceResourceIds)) {
|
if (StringUtils.isEmpty(sourceResourceIds)) {
|
||||||
|
|
|
@ -27,6 +27,11 @@
|
||||||
<artifactId>hapi-fhir-server</artifactId>
|
<artifactId>hapi-fhir-server</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.data</groupId>
|
||||||
|
<artifactId>spring-data-commons</artifactId>
|
||||||
|
<version>${spring_data_version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-structures-dstu3</artifactId>
|
<artifactId>hapi-fhir-structures-dstu3</artifactId>
|
||||||
|
|
|
@ -20,17 +20,18 @@ package ca.uhn.fhir.mdm.api;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.mdm.api.paging.MdmPageRequest;
|
||||||
import ca.uhn.fhir.mdm.model.MdmTransactionContext;
|
import ca.uhn.fhir.mdm.model.MdmTransactionContext;
|
||||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public interface IMdmControllerSvc {
|
public interface IMdmControllerSvc {
|
||||||
|
|
||||||
Stream<MdmLinkJson> queryLinks(@Nullable String theGoldenResourceId, @Nullable String theSourceResourceId, @Nullable String theMatchResult, @Nullable String theLinkSource, MdmTransactionContext theMdmTransactionContext, int theOffset, int theCount);
|
Page<MdmLinkJson> queryLinks(@Nullable String theGoldenResourceId, @Nullable String theSourceResourceId, @Nullable String theMatchResult, @Nullable String theLinkSource, MdmTransactionContext theMdmTransactionContext, MdmPageRequest thePageRequest);
|
||||||
|
|
||||||
Stream<MdmLinkJson> getDuplicateGoldenResources(MdmTransactionContext theMdmTransactionContext, int theOffset, int theCount);
|
Page<MdmLinkJson> getDuplicateGoldenResources(MdmTransactionContext theMdmTransactionContext, MdmPageRequest thePageRequest);
|
||||||
|
|
||||||
void notDuplicateGoldenResource(String theGoldenResourceId, String theTargetGoldenResourceId, MdmTransactionContext theMdmTransactionContext);
|
void notDuplicateGoldenResource(String theGoldenResourceId, String theTargetGoldenResourceId, MdmTransactionContext theMdmTransactionContext);
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,15 @@ package ca.uhn.fhir.mdm.api;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import ca.uhn.fhir.mdm.api.paging.MdmPageRequest;
|
||||||
import ca.uhn.fhir.mdm.model.MdmTransactionContext;
|
import ca.uhn.fhir.mdm.model.MdmTransactionContext;
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This service supports the MDM operation providers for those services that return multiple MDM links.
|
* This service supports the MDM operation providers for those services that return multiple MDM links.
|
||||||
*/
|
*/
|
||||||
public interface IMdmLinkQuerySvc {
|
public interface IMdmLinkQuerySvc {
|
||||||
Stream<MdmLinkJson> queryLinks(IIdType theGoldenResourceId, IIdType theSourceResourceId, MdmMatchResultEnum theMatchResult, MdmLinkSourceEnum theLinkSource, MdmTransactionContext theMdmContext, int theOffset, int theCount);
|
Page<MdmLinkJson> queryLinks(IIdType theGoldenResourceId, IIdType theSourceResourceId, MdmMatchResultEnum theMatchResult, MdmLinkSourceEnum theLinkSource, MdmTransactionContext theMdmContext, MdmPageRequest thePageRequest);
|
||||||
Stream<MdmLinkJson> getDuplicateGoldenResources(MdmTransactionContext theMdmContext, int theOffset, int theCount);
|
Page<MdmLinkJson> getDuplicateGoldenResources(MdmTransactionContext theMdmContext, MdmPageRequest thePageRequest);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package ca.uhn.fhir.mdm.api.paging;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.mdm.api.MdmLinkJson;
|
||||||
|
import ca.uhn.fhir.rest.server.RestfulServerUtils;
|
||||||
|
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||||
|
import ca.uhn.fhir.util.ParametersUtil;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import static ca.uhn.fhir.rest.api.Constants.PARAM_COUNT;
|
||||||
|
import static ca.uhn.fhir.rest.api.Constants.PARAM_OFFSET;
|
||||||
|
|
||||||
|
public final class MdmPageLinkBuilder {
|
||||||
|
public static MdmPageLinkTuple buildMdmPageLinks(ServletRequestDetails theServletRequestDetails, Page<MdmLinkJson> theCurrentPage, MdmPageRequest thePageRequest) {
|
||||||
|
MdmPageLinkTuple tuple = new MdmPageLinkTuple();
|
||||||
|
String urlWithoutPaging = RestfulServerUtils.createLinkSelfWithoutGivenParameters(theServletRequestDetails.getFhirServerBase(), theServletRequestDetails, Arrays.asList(PARAM_OFFSET, PARAM_COUNT));
|
||||||
|
tuple.setSelfLink(buildLinkWithOffsetAndCount(urlWithoutPaging, thePageRequest.getCount(), thePageRequest.getOffset()));
|
||||||
|
if (theCurrentPage.hasNext()) {
|
||||||
|
tuple.setNextLink(buildLinkWithOffsetAndCount(urlWithoutPaging,thePageRequest.getCount(), thePageRequest.getNextOffset()));
|
||||||
|
}
|
||||||
|
if (theCurrentPage.hasPrevious()) {
|
||||||
|
tuple.setPreviousLink(buildLinkWithOffsetAndCount(urlWithoutPaging,thePageRequest.getCount(), thePageRequest.getPreviousOffset()));
|
||||||
|
}
|
||||||
|
return tuple;
|
||||||
|
|
||||||
|
}
|
||||||
|
protected static String buildLinkWithOffsetAndCount(String theStartingUrl, int theCount, int theOffset) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append(theStartingUrl);
|
||||||
|
if (!theStartingUrl.contains("?")) {
|
||||||
|
builder.append("?");
|
||||||
|
}
|
||||||
|
builder.append(PARAM_OFFSET).append("=").append(theOffset);
|
||||||
|
builder.append(PARAM_COUNT).append("=").append(theCount);
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package ca.uhn.fhir.mdm.api.paging;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class MdmPageLinkTuple {
|
||||||
|
private String myPreviousLink = null;
|
||||||
|
private String mySelfLink = null;
|
||||||
|
private String myNextLink = null;
|
||||||
|
|
||||||
|
MdmPageLinkTuple() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<String> getPreviousLink() {
|
||||||
|
return Optional.ofNullable(myPreviousLink);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPreviousLink(String thePreviousLink) {
|
||||||
|
this.myPreviousLink = thePreviousLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelfLink() {
|
||||||
|
return mySelfLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelfLink(String theSelfLink) {
|
||||||
|
this.mySelfLink = theSelfLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<String> getNextLink() {
|
||||||
|
return Optional.ofNullable(myNextLink);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNextLink(String theNextLink) {
|
||||||
|
this.myNextLink = theNextLink;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
package ca.uhn.fhir.mdm.api.paging;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.rest.server.IRestfulServerDefaults;
|
||||||
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.hl7.fhir.dstu3.model.UnsignedIntType;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
|
||||||
|
import static ca.uhn.fhir.rest.api.Constants.PARAM_COUNT;
|
||||||
|
import static ca.uhn.fhir.rest.api.Constants.PARAM_OFFSET;
|
||||||
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
|
||||||
|
public class MdmPageRequest {
|
||||||
|
private static final Logger ourLog = getLogger(MdmPageRequest.class);
|
||||||
|
|
||||||
|
private int myPage;
|
||||||
|
private int myOffset;
|
||||||
|
private int myCount;
|
||||||
|
private IRestfulServerDefaults myRestfulServerDefaults;
|
||||||
|
|
||||||
|
public MdmPageRequest(UnsignedIntType theOffset, UnsignedIntType theCount, IRestfulServerDefaults theDefaults) {
|
||||||
|
myOffset = theOffset == null ? 0 : theOffset.getValue();
|
||||||
|
myCount = theCount == null ? theDefaults.getDefaultPageSize() : theCount.getValue();
|
||||||
|
validatePagingParameters(myOffset, myCount);
|
||||||
|
|
||||||
|
this.myPage = myOffset / myCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageRequest toPageRequest() {
|
||||||
|
return PageRequest.of(this.myPage, this.myCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validatePagingParameters(int theOffset, int theCount) {
|
||||||
|
String errorMessage = "";
|
||||||
|
|
||||||
|
if (theOffset < 0) {
|
||||||
|
errorMessage += PARAM_OFFSET + " must be greater than or equal to 0. ";
|
||||||
|
}
|
||||||
|
if (theCount <= 0 ) {
|
||||||
|
errorMessage += PARAM_COUNT + " must be greater than 0.";
|
||||||
|
}
|
||||||
|
if (myRestfulServerDefaults.getMaximumPageSize() != null && theCount > myRestfulServerDefaults.getMaximumPageSize() ) {
|
||||||
|
ourLog.debug("Shrinking page size down to {}, as this is the maximum allowed.", myRestfulServerDefaults.getMaximumPageSize());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(errorMessage)) {
|
||||||
|
throw new InvalidRequestException(errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOffset() {
|
||||||
|
return myOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPage() {
|
||||||
|
return myPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCount() {
|
||||||
|
return myCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNextOffset() {
|
||||||
|
return myOffset + myCount;
|
||||||
|
}
|
||||||
|
public int getPreviousOffset() {
|
||||||
|
return myOffset - myCount;
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,17 +23,26 @@ package ca.uhn.fhir.mdm.provider;
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.mdm.api.MdmLinkJson;
|
import ca.uhn.fhir.mdm.api.MdmLinkJson;
|
||||||
import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
|
import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
|
||||||
|
import ca.uhn.fhir.mdm.api.paging.MdmPageLinkBuilder;
|
||||||
|
import ca.uhn.fhir.mdm.api.paging.MdmPageLinkTuple;
|
||||||
|
import ca.uhn.fhir.mdm.api.paging.MdmPageRequest;
|
||||||
import ca.uhn.fhir.mdm.model.MdmTransactionContext;
|
import ca.uhn.fhir.mdm.model.MdmTransactionContext;
|
||||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||||
|
import ca.uhn.fhir.rest.server.RestfulServerUtils;
|
||||||
import ca.uhn.fhir.rest.server.TransactionLogMessages;
|
import ca.uhn.fhir.rest.server.TransactionLogMessages;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
import ca.uhn.fhir.rest.server.provider.ProviderConstants;
|
import ca.uhn.fhir.rest.server.provider.ProviderConstants;
|
||||||
|
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||||
import ca.uhn.fhir.util.ParametersUtil;
|
import ca.uhn.fhir.util.ParametersUtil;
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseParameters;
|
import org.hl7.fhir.instance.model.api.IBaseParameters;
|
||||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
|
||||||
import java.util.stream.Stream;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import static ca.uhn.fhir.rest.api.Constants.PARAM_COUNT;
|
||||||
|
import static ca.uhn.fhir.rest.api.Constants.PARAM_OFFSET;
|
||||||
|
|
||||||
public abstract class BaseMdmProvider {
|
public abstract class BaseMdmProvider {
|
||||||
|
|
||||||
|
@ -92,9 +101,9 @@ public abstract class BaseMdmProvider {
|
||||||
return theString.getValue();
|
return theString.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IBaseParameters parametersFromMdmLinks(Stream<MdmLinkJson> theMdmLinkStream, boolean includeResultAndSource) {
|
protected IBaseParameters parametersFromMdmLinks(Page<MdmLinkJson> theMdmLinkStream, boolean includeResultAndSource, ServletRequestDetails theServletRequestDetails, MdmPageRequest thePageRequest) {
|
||||||
IBaseParameters retval = ParametersUtil.newInstance(myFhirContext);
|
IBaseParameters retval = ParametersUtil.newInstance(myFhirContext);
|
||||||
|
addPagingParameters(retval, theMdmLinkStream, theServletRequestDetails, thePageRequest);
|
||||||
theMdmLinkStream.forEach(mdmLink -> {
|
theMdmLinkStream.forEach(mdmLink -> {
|
||||||
IBase resultPart = ParametersUtil.addParameterToParameters(myFhirContext, retval, "link");
|
IBase resultPart = ParametersUtil.addParameterToParameters(myFhirContext, retval, "link");
|
||||||
ParametersUtil.addPartString(myFhirContext, resultPart, "goldenResourceId", mdmLink.getGoldenResourceId());
|
ParametersUtil.addPartString(myFhirContext, resultPart, "goldenResourceId", mdmLink.getGoldenResourceId());
|
||||||
|
@ -111,4 +120,15 @@ public abstract class BaseMdmProvider {
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void addPagingParameters(IBaseParameters theParameters, Page<MdmLinkJson> theCurrentPage, ServletRequestDetails theServletRequestDetails, MdmPageRequest thePageRequest) {
|
||||||
|
MdmPageLinkTuple mdmPageLinkTuple = MdmPageLinkBuilder.buildMdmPageLinks(theServletRequestDetails, theCurrentPage, thePageRequest);
|
||||||
|
ParametersUtil.addParameterToParametersUri(myFhirContext, theParameters, "self", mdmPageLinkTuple.getSelfLink());
|
||||||
|
|
||||||
|
if (mdmPageLinkTuple.getNextLink().isPresent()) {
|
||||||
|
ParametersUtil.addParameterToParametersUri(myFhirContext, theParameters, "next", mdmPageLinkTuple.getNextLink().get());
|
||||||
|
}
|
||||||
|
if (mdmPageLinkTuple.getPreviousLink().isPresent()) {
|
||||||
|
ParametersUtil.addParameterToParametersUri(myFhirContext, theParameters, "prev", mdmPageLinkTuple.getPreviousLink().get());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import ca.uhn.fhir.mdm.api.IMdmSubmitSvc;
|
||||||
import ca.uhn.fhir.mdm.api.MatchedTarget;
|
import ca.uhn.fhir.mdm.api.MatchedTarget;
|
||||||
import ca.uhn.fhir.mdm.api.MdmConstants;
|
import ca.uhn.fhir.mdm.api.MdmConstants;
|
||||||
import ca.uhn.fhir.mdm.api.MdmLinkJson;
|
import ca.uhn.fhir.mdm.api.MdmLinkJson;
|
||||||
|
import ca.uhn.fhir.mdm.api.paging.MdmPageRequest;
|
||||||
import ca.uhn.fhir.mdm.model.MdmTransactionContext;
|
import ca.uhn.fhir.mdm.model.MdmTransactionContext;
|
||||||
import ca.uhn.fhir.model.api.annotation.Description;
|
import ca.uhn.fhir.model.api.annotation.Description;
|
||||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||||
|
@ -35,6 +36,7 @@ import ca.uhn.fhir.rest.annotation.Operation;
|
||||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||||
import ca.uhn.fhir.rest.api.Constants;
|
import ca.uhn.fhir.rest.api.Constants;
|
||||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||||
|
import ca.uhn.fhir.rest.server.IRestfulServerDefaults;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
import ca.uhn.fhir.rest.server.provider.ProviderConstants;
|
import ca.uhn.fhir.rest.server.provider.ProviderConstants;
|
||||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||||
|
@ -52,6 +54,8 @@ import org.hl7.fhir.instance.model.api.IBaseParameters;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
@ -59,17 +63,19 @@ import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import static ca.uhn.fhir.rest.api.Constants.PARAM_COUNT;
|
|
||||||
import static ca.uhn.fhir.rest.api.Constants.PARAM_OFFSET;
|
import static ca.uhn.fhir.rest.api.Constants.PARAM_OFFSET;
|
||||||
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
|
||||||
public class MdmProviderDstu3Plus extends BaseMdmProvider {
|
public class MdmProviderDstu3Plus extends BaseMdmProvider {
|
||||||
|
private static final Logger ourLog = getLogger(MdmProviderDstu3Plus.class);
|
||||||
|
|
||||||
|
|
||||||
private final IMdmControllerSvc myMdmControllerSvc;
|
private final IMdmControllerSvc myMdmControllerSvc;
|
||||||
private final IMdmMatchFinderSvc myMdmMatchFinderSvc;
|
private final IMdmMatchFinderSvc myMdmMatchFinderSvc;
|
||||||
private final IMdmExpungeSvc myMdmExpungeSvc;
|
private final IMdmExpungeSvc myMdmExpungeSvc;
|
||||||
private final IMdmSubmitSvc myMdmSubmitSvc;
|
private final IMdmSubmitSvc myMdmSubmitSvc;
|
||||||
|
private final IRestfulServerDefaults myRestfulServerDefaults;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -77,12 +83,13 @@ public class MdmProviderDstu3Plus extends BaseMdmProvider {
|
||||||
* Note that this is not a spring bean. Any necessary injections should
|
* Note that this is not a spring bean. Any necessary injections should
|
||||||
* happen in the constructor
|
* happen in the constructor
|
||||||
*/
|
*/
|
||||||
public MdmProviderDstu3Plus(FhirContext theFhirContext, IMdmControllerSvc theMdmControllerSvc, IMdmMatchFinderSvc theMdmMatchFinderSvc, IMdmExpungeSvc theMdmExpungeSvc, IMdmSubmitSvc theMdmSubmitSvc) {
|
public MdmProviderDstu3Plus(FhirContext theFhirContext, IMdmControllerSvc theMdmControllerSvc, IMdmMatchFinderSvc theMdmMatchFinderSvc, IMdmExpungeSvc theMdmExpungeSvc, IMdmSubmitSvc theMdmSubmitSvc, IRestfulServerDefaults theRestfulServerDefaults) {
|
||||||
super(theFhirContext);
|
super(theFhirContext);
|
||||||
myMdmControllerSvc = theMdmControllerSvc;
|
myMdmControllerSvc = theMdmControllerSvc;
|
||||||
myMdmMatchFinderSvc = theMdmMatchFinderSvc;
|
myMdmMatchFinderSvc = theMdmMatchFinderSvc;
|
||||||
myMdmExpungeSvc = theMdmExpungeSvc;
|
myMdmExpungeSvc = theMdmExpungeSvc;
|
||||||
myMdmSubmitSvc = theMdmSubmitSvc;
|
myMdmSubmitSvc = theMdmSubmitSvc;
|
||||||
|
myRestfulServerDefaults = theRestfulServerDefaults;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(name = ProviderConstants.EMPI_MATCH, typeName = "Patient")
|
@Operation(name = ProviderConstants.EMPI_MATCH, typeName = "Patient")
|
||||||
|
@ -199,40 +206,38 @@ public class MdmProviderDstu3Plus extends BaseMdmProvider {
|
||||||
IPrimitiveType<String> theLinkSource,
|
IPrimitiveType<String> theLinkSource,
|
||||||
|
|
||||||
@Description(formalDefinition="Results from this method are returned across multiple pages. This parameter controls the offset when fetching a page.")
|
@Description(formalDefinition="Results from this method are returned across multiple pages. This parameter controls the offset when fetching a page.")
|
||||||
@OperationParam(name = PARAM_OFFSET)
|
@OperationParam(name = PARAM_OFFSET, min = 0, max = 1)
|
||||||
UnsignedIntType theOffset,
|
UnsignedIntType theOffset,
|
||||||
@Description(formalDefinition = "Results from this method are returned across multiple pages. This parameter controls the size of those pages.")
|
@Description(formalDefinition = "Results from this method are returned across multiple pages. This parameter controls the size of those pages.")
|
||||||
@OperationParam(name = Constants.PARAM_COUNT)
|
@OperationParam(name = Constants.PARAM_COUNT, min = 0, max = 1)
|
||||||
UnsignedIntType theCount,
|
UnsignedIntType theCount,
|
||||||
|
|
||||||
ServletRequestDetails theRequestDetails) {
|
ServletRequestDetails theRequestDetails) {
|
||||||
validatePagingParameters(theOffset, theCount);
|
MdmPageRequest mdmPageRequest = new MdmPageRequest(theOffset, theCount, myRestfulServerDefaults);
|
||||||
|
Page<MdmLinkJson> mdmLinkJson = myMdmControllerSvc.queryLinks(extractStringOrNull(theGoldenResourceId),
|
||||||
Stream<MdmLinkJson> mdmLinkJson = myMdmControllerSvc.queryLinks(extractStringOrNull(theGoldenResourceId),
|
|
||||||
extractStringOrNull(theResourceId), extractStringOrNull(theMatchResult), extractStringOrNull(theLinkSource),
|
extractStringOrNull(theResourceId), extractStringOrNull(theMatchResult), extractStringOrNull(theLinkSource),
|
||||||
createMdmContext(theRequestDetails, MdmTransactionContext.OperationType.QUERY_LINKS,
|
createMdmContext(theRequestDetails, MdmTransactionContext.OperationType.QUERY_LINKS,
|
||||||
getResourceType(ProviderConstants.MDM_QUERY_LINKS_GOLDEN_RESOURCE_ID, theGoldenResourceId)), theOffset.getValue(), theCount.getValue()
|
getResourceType(ProviderConstants.MDM_QUERY_LINKS_GOLDEN_RESOURCE_ID, theGoldenResourceId)), mdmPageRequest);
|
||||||
);
|
|
||||||
return parametersFromMdmLinks(mdmLinkJson, true);
|
return parametersFromMdmLinks(mdmLinkJson, true, theRequestDetails, mdmPageRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validatePagingParameters(UnsignedIntType theOffset, UnsignedIntType theCount) {
|
|
||||||
String errorMessage = "";
|
|
||||||
if (theOffset!= null && theOffset.getValue() < 0) {
|
|
||||||
errorMessage += PARAM_OFFSET + " must be greater than or equal to 0. ";
|
|
||||||
}
|
|
||||||
if (theCount != null && theCount.getValue() <= 0 ) {
|
|
||||||
errorMessage += PARAM_COUNT + " must be greater than 0.";
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(errorMessage)) {
|
|
||||||
throw new InvalidRequestException(errorMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(name = ProviderConstants.MDM_DUPLICATE_GOLDEN_RESOURCES, idempotent = true)
|
@Operation(name = ProviderConstants.MDM_DUPLICATE_GOLDEN_RESOURCES, idempotent = true)
|
||||||
public IBaseParameters getDuplicateGoldenResources(ServletRequestDetails theRequestDetails) {
|
public IBaseParameters getDuplicateGoldenResources(
|
||||||
Stream<MdmLinkJson> possibleDuplicates = myMdmControllerSvc.getDuplicateGoldenResources(createMdmContext(theRequestDetails, MdmTransactionContext.OperationType.DUPLICATE_GOLDEN_RESOURCES, (String) null),0,10);
|
@Description(formalDefinition="Results from this method are returned across multiple pages. This parameter controls the offset when fetching a page.")
|
||||||
return parametersFromMdmLinks(possibleDuplicates, false);
|
@OperationParam(name = PARAM_OFFSET, min = 0, max = 1)
|
||||||
|
UnsignedIntType theOffset,
|
||||||
|
@Description(formalDefinition = "Results from this method are returned across multiple pages. This parameter controls the size of those pages.")
|
||||||
|
@OperationParam(name = Constants.PARAM_COUNT, min = 0, max = 1)
|
||||||
|
UnsignedIntType theCount,
|
||||||
|
ServletRequestDetails theRequestDetails) {
|
||||||
|
|
||||||
|
MdmPageRequest mdmPageRequest = new MdmPageRequest(theOffset, theCount, myRestfulServerDefaults);
|
||||||
|
|
||||||
|
Page<MdmLinkJson> possibleDuplicates = myMdmControllerSvc.getDuplicateGoldenResources(createMdmContext(theRequestDetails, MdmTransactionContext.OperationType.DUPLICATE_GOLDEN_RESOURCES, (String) null), mdmPageRequest);
|
||||||
|
|
||||||
|
return parametersFromMdmLinks(possibleDuplicates, false, theRequestDetails, mdmPageRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(name = ProviderConstants.MDM_NOT_DUPLICATE)
|
@Operation(name = ProviderConstants.MDM_NOT_DUPLICATE)
|
||||||
|
@ -260,7 +265,6 @@ public class MdmProviderDstu3Plus extends BaseMdmProvider {
|
||||||
ServletRequestDetails theRequestDetails) {
|
ServletRequestDetails theRequestDetails) {
|
||||||
String criteria = convertStringTypeToString(theCriteria);
|
String criteria = convertStringTypeToString(theCriteria);
|
||||||
String resourceType = convertStringTypeToString(theResourceType);
|
String resourceType = convertStringTypeToString(theResourceType);
|
||||||
|
|
||||||
long submittedCount;
|
long submittedCount;
|
||||||
if (resourceType != null) {
|
if (resourceType != null) {
|
||||||
submittedCount = myMdmSubmitSvc.submitSourceResourceTypeToMdm(resourceType, criteria);
|
submittedCount = myMdmSubmitSvc.submitSourceResourceTypeToMdm(resourceType, criteria);
|
||||||
|
|
|
@ -26,6 +26,7 @@ import ca.uhn.fhir.mdm.api.IMdmControllerSvc;
|
||||||
import ca.uhn.fhir.mdm.api.IMdmExpungeSvc;
|
import ca.uhn.fhir.mdm.api.IMdmExpungeSvc;
|
||||||
import ca.uhn.fhir.mdm.api.IMdmMatchFinderSvc;
|
import ca.uhn.fhir.mdm.api.IMdmMatchFinderSvc;
|
||||||
import ca.uhn.fhir.mdm.api.IMdmSubmitSvc;
|
import ca.uhn.fhir.mdm.api.IMdmSubmitSvc;
|
||||||
|
import ca.uhn.fhir.rest.server.IRestfulServerDefaults;
|
||||||
import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory;
|
import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -46,6 +47,8 @@ public class MdmProviderLoader {
|
||||||
private IMdmExpungeSvc myMdmExpungeSvc;
|
private IMdmExpungeSvc myMdmExpungeSvc;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IMdmSubmitSvc myMdmSubmitSvc;
|
private IMdmSubmitSvc myMdmSubmitSvc;
|
||||||
|
@Autowired
|
||||||
|
private IRestfulServerDefaults myRestfulServerDefaults;
|
||||||
|
|
||||||
private BaseMdmProvider myMdmProvider;
|
private BaseMdmProvider myMdmProvider;
|
||||||
|
|
||||||
|
@ -54,7 +57,7 @@ public class MdmProviderLoader {
|
||||||
case DSTU3:
|
case DSTU3:
|
||||||
case R4:
|
case R4:
|
||||||
myResourceProviderFactory.addSupplier(() -> {
|
myResourceProviderFactory.addSupplier(() -> {
|
||||||
myMdmProvider = new MdmProviderDstu3Plus(myFhirContext, myMdmControllerSvc, myMdmMatchFinderSvc, myMdmExpungeSvc, myMdmSubmitSvc);
|
myMdmProvider = new MdmProviderDstu3Plus(myFhirContext, myMdmControllerSvc, myMdmMatchFinderSvc, myMdmExpungeSvc, myMdmSubmitSvc, myRestfulServerDefaults);
|
||||||
return myMdmProvider;
|
return myMdmProvider;
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -249,6 +249,10 @@ public class RestfulServerUtils {
|
||||||
|
|
||||||
|
|
||||||
public static String createLinkSelf(String theServerBase, RequestDetails theRequest) {
|
public static String createLinkSelf(String theServerBase, RequestDetails theRequest) {
|
||||||
|
return createLinkSelfWithoutGivenParameters(theServerBase, theRequest, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String createLinkSelfWithoutGivenParameters(String theServerBase, RequestDetails theRequest, List<String> excludedParameterNames) {
|
||||||
StringBuilder b = new StringBuilder();
|
StringBuilder b = new StringBuilder();
|
||||||
b.append(theServerBase);
|
b.append(theServerBase);
|
||||||
|
|
||||||
|
@ -265,21 +269,24 @@ public class RestfulServerUtils {
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
Map<String, String[]> parameters = theRequest.getParameters();
|
Map<String, String[]> parameters = theRequest.getParameters();
|
||||||
for (String nextParamName : new TreeSet<>(parameters.keySet())) {
|
for (String nextParamName : new TreeSet<>(parameters.keySet())) {
|
||||||
for (String nextParamValue : parameters.get(nextParamName)) {
|
if (excludedParameterNames != null && !excludedParameterNames.contains(nextParamName)) {
|
||||||
if (first) {
|
for (String nextParamValue : parameters.get(nextParamName)) {
|
||||||
b.append('?');
|
if (first) {
|
||||||
first = false;
|
b.append('?');
|
||||||
} else {
|
first = false;
|
||||||
b.append('&');
|
} else {
|
||||||
|
b.append('&');
|
||||||
|
}
|
||||||
|
b.append(UrlUtil.escapeUrlParam(nextParamName));
|
||||||
|
b.append('=');
|
||||||
|
b.append(UrlUtil.escapeUrlParam(nextParamValue));
|
||||||
}
|
}
|
||||||
b.append(UrlUtil.escapeUrlParam(nextParamName));
|
|
||||||
b.append('=');
|
|
||||||
b.append(UrlUtil.escapeUrlParam(nextParamValue));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return b.toString();
|
return b.toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String createOffsetPagingLink(BundleLinks theBundleLinks, String requestPath, String tenantId, Integer theOffset, Integer theCount, Map<String, String[]> theRequestParameters) {
|
public static String createOffsetPagingLink(BundleLinks theBundleLinks, String requestPath, String tenantId, Integer theOffset, Integer theCount, Map<String, String[]> theRequestParameters) {
|
||||||
|
|
Loading…
Reference in New Issue