Skip to content

Commit

Permalink
Trying to get test working
Browse files Browse the repository at this point in the history
  • Loading branch information
tadgh committed Feb 13, 2025
1 parent 5177229 commit 46cb1bf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
package ca.uhn.fhir.jpa.dao.r4;

import static org.junit.jupiter.api.Assertions.assertEquals;

import ca.uhn.fhir.jpa.api.dao.PatientEverythingParameters;
import ca.uhn.fhir.jpa.binary.provider.BinaryAccessProvider;
import ca.uhn.fhir.jpa.rp.r4.PatientResourceProvider;
import ca.uhn.fhir.jpa.search.PersistedJpaBundleProvider;
import ca.uhn.fhir.jpa.search.cache.SearchCacheStatusEnum;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.jpa.util.SqlQuery;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
import ca.uhn.fhir.rest.api.server.SystemRequestDetails;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.r4.model.IntegerType;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

Expand All @@ -19,12 +29,37 @@
@SuppressWarnings("unchecked")
public class PartitioningSearchCacheR4Test extends BasePartitioningR4Test {
private static final Logger ourLog = LoggerFactory.getLogger(PartitioningSearchCacheR4Test.class);
@Autowired
protected PatientResourceProvider myPatientResourceProvider;


@Test
public void testPartitioningDoesNotReturnDuplicatesOnPatientEverything() {

IIdType patient = createPatient(withPartition(1), withActiveTrue());

List<IIdType> referencedEncounters = new ArrayList<>();

for (int i = 0; i < 7; i++) {
IIdType encounter = createEncounter(withPartition(1), withId("enc-" + i), withIdentifier("http://example.com/", "code"));
referencedEncounters.add(encounter);
}
IIdType nonReferencedEncounter = createEncounter(withPartition(1), withId("enc-1"), withIdentifier("http://example.com/", "code"));
for (int i = 0; i <50; i++) {
IIdType encounterToReference = referencedEncounters.get(i % referencedEncounters.size());
createObservation(withPartition(1), withId("obs-" + i ), withSubject(patient), withObservationCode("http://example.com/", "code"), withEncounter(encounterToReference));
}

createObservation(withPartition(1), withId("obs-1"), withSubject(patient), withObservationCode("http://example.com/", "code"));
PatientEverythingParameters params = new PatientEverythingParameters();
params.setCount(new IntegerType(50));
addReadPartition(1);

IBundleProvider iBundleProvider = myPatientDao.patientInstanceEverything(null, mySrd, params, patient);

List<IBaseResource> resources = iBundleProvider.getResources(0, 100);
assertThat(resources).hasSize(50);
assertThat(resources).extracting(resource -> resource.getIdElement().getValue()).doesNotHaveDuplicates();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,11 @@ default ICreationArgument withGroupMember(@Nullable String theMember) {
}

default ICreationArgument withEncounter(@Nullable String theEncounter) {
return withReference("encounter", new IdType(theEncounter));
return withEncounter(new IdType(theEncounter));
}

default ICreationArgument withEncounter(@Nullable IIdType theEncounter) {
return withReference("encounter", theEncounter);
}

@Nonnull
Expand Down

0 comments on commit 46cb1bf

Please sign in to comment.