Add two new tests. Fix non-jupiter-tests

This commit is contained in:
Tadgh 2020-07-21 08:51:18 -07:00
parent 4ec2be4ff5
commit 249f5e5947
4 changed files with 49 additions and 12 deletions

View File

@ -47,8 +47,8 @@ public class EmpiBatchSvcImpl implements IEmpiBatchService {
@Transactional @Transactional
public int runEmpiOnAllTargetTypes(String theCriteria) { public int runEmpiOnAllTargetTypes(String theCriteria) {
int submittedCount = 0; int submittedCount = 0;
submittedCount += runEmpiOnTargetType("Patient", theCriteria); submittedCount += runEmpiOnPatientType(theCriteria);
submittedCount += runEmpiOnTargetType("Practitioner", theCriteria); submittedCount += runEmpiOnPractitionerType(theCriteria);
return submittedCount; return submittedCount;
} }
@ -69,7 +69,6 @@ public class EmpiBatchSvcImpl implements IEmpiBatchService {
while (query.hasNext()) { while (query.hasNext()) {
pidsToSubmit.add(query.next()); pidsToSubmit.add(query.next());
if (pidsToSubmit.size() == QUEUE_ADDING_PAGE_SIZE || !query.hasNext()) { if (pidsToSubmit.size() == QUEUE_ADDING_PAGE_SIZE || !query.hasNext()) {
//TODO GGG ask ken how this works.
total = loadResourcesAndSubmitToEmpi(total, mySearchBuilder, pidsToSubmit, resourceToBeSubmitted); total = loadResourcesAndSubmitToEmpi(total, mySearchBuilder, pidsToSubmit, resourceToBeSubmitted);
resourceToBeSubmitted.clear(); resourceToBeSubmitted.clear();
} }
@ -81,6 +80,7 @@ public class EmpiBatchSvcImpl implements IEmpiBatchService {
} }
private int loadResourcesAndSubmitToEmpi(int theTotal, ISearchBuilder theMySearchBuilder, Collection<ResourcePersistentId> thePidsToSubmit, List<IBaseResource> theResourceToBeSubmitted) { private int loadResourcesAndSubmitToEmpi(int theTotal, ISearchBuilder theMySearchBuilder, Collection<ResourcePersistentId> thePidsToSubmit, List<IBaseResource> theResourceToBeSubmitted) {
//TODO GGG ask ken how this works. specifically includePids?
theMySearchBuilder.loadResourcesByPid(thePidsToSubmit, thePidsToSubmit, theResourceToBeSubmitted, false, null); theMySearchBuilder.loadResourcesByPid(thePidsToSubmit, thePidsToSubmit, theResourceToBeSubmitted, false, null);
theResourceToBeSubmitted theResourceToBeSubmitted
.forEach(resource -> myEmpiQueueSubmitterSvc.manuallySubmitResourceToEmpi(resource)); .forEach(resource -> myEmpiQueueSubmitterSvc.manuallySubmitResourceToEmpi(resource));
@ -113,13 +113,13 @@ public class EmpiBatchSvcImpl implements IEmpiBatchService {
@Override @Override
@Transactional @Transactional
public int runEmpiOnTargetPractitioner(IIdType theId) { public int runEmpiOnTargetPractitioner(IIdType theId) {
return runEmpiOnTarget(theId, "practitioner"); return runEmpiOnTarget(theId, "Practitioner");
} }
@Override @Override
@Transactional @Transactional
public int runEmpiOnTargetPatient(IIdType theId) { public int runEmpiOnTargetPatient(IIdType theId) {
return runEmpiOnTarget(theId, "patient"); return runEmpiOnTarget(theId, "Patient");
} }
private SearchParameterMap getSearchParameterMapFromCriteria(String theTargetType, String theCriteria) { private SearchParameterMap getSearchParameterMapFromCriteria(String theTargetType, String theCriteria) {

View File

@ -3,7 +3,9 @@ package ca.uhn.fhir.jpa.empi.provider;
import ca.uhn.fhir.interceptor.api.IInterceptorService; import ca.uhn.fhir.interceptor.api.IInterceptorService;
import ca.uhn.fhir.interceptor.api.Pointcut; import ca.uhn.fhir.interceptor.api.Pointcut;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.test.concurrency.PointcutLatch; import ca.uhn.test.concurrency.PointcutLatch;
import org.hl7.fhir.r4.model.IdType;
import org.hl7.fhir.r4.model.Person; import org.hl7.fhir.r4.model.Person;
import org.hl7.fhir.r4.model.Practitioner; import org.hl7.fhir.r4.model.Practitioner;
import org.hl7.fhir.r4.model.StringType; import org.hl7.fhir.r4.model.StringType;
@ -54,6 +56,23 @@ public class EmpiProviderBatchR4Test extends BaseLinkR4Test {
afterEmpiLatch.runWithExpectedCount(1, () -> myEmpiProviderR4.empiBatchPractitionerType(criteria, null)); afterEmpiLatch.runWithExpectedCount(1, () -> myEmpiProviderR4.empiBatchPractitionerType(criteria, null));
assertLinkCount(1); assertLinkCount(1);
} }
@Test
public void testBatchRunOnSpecificPractitioner() {
assertLinkCount(2);
myEmpiProviderR4.clearEmpiLinks(null);
afterEmpiLatch.runWithExpectedCount(1, () -> myEmpiProviderR4.empiBatchPractitionerInstance(myPractitioner.getIdElement(), null));
assertLinkCount(1);
}
@Test
public void testBatchRunOnNonExistentSpecificPractitioner() {
assertLinkCount(2);
myEmpiProviderR4.clearEmpiLinks(null);
try {
myEmpiProviderR4.empiBatchPractitionerInstance(new IdType("Practitioner/999"), null);
fail();
} catch (ResourceNotFoundException e){}
}
@Test @Test
public void testBatchRunOnAllPatients() { public void testBatchRunOnAllPatients() {
@ -64,6 +83,24 @@ public class EmpiProviderBatchR4Test extends BaseLinkR4Test {
assertLinkCount(1); assertLinkCount(1);
} }
@Test
public void testBatchRunOnSpecificPatient() {
assertLinkCount(2);
myEmpiProviderR4.clearEmpiLinks(null);
afterEmpiLatch.runWithExpectedCount(1, () -> myEmpiProviderR4.empiBatchPatientInstance(myPatient.getIdElement(), null));
assertLinkCount(1);
}
@Test
public void testBatchRunOnNonExistentSpecificPatient() {
assertLinkCount(2);
myEmpiProviderR4.clearEmpiLinks(null);
try {
myEmpiProviderR4.empiBatchPatientInstance(new IdType("Patient/999"), null);
fail();
} catch (ResourceNotFoundException e){}
}
@Test @Test
public void testBatchRunOnAllTypes() { public void testBatchRunOnAllTypes() {
assertLinkCount(2); assertLinkCount(2);

View File

@ -6,10 +6,10 @@ import org.hl7.fhir.dstu3.model.CodeType;
import org.hl7.fhir.dstu3.model.Patient; import org.hl7.fhir.dstu3.model.Patient;
import org.hl7.fhir.dstu3.model.Reference; import org.hl7.fhir.dstu3.model.Reference;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import org.junit.Test; import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertSame; import static org.junit.jupiter.api.Assertions.assertSame;
public class ExtendedPatientTest { public class ExtendedPatientTest {

View File

@ -1,15 +1,15 @@
package ca.uhn.fhir.parser; package ca.uhn.fhir.parser;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.CodeType; import org.hl7.fhir.r4.model.CodeType;
import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Reference; import org.hl7.fhir.r4.model.Reference;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.junit.jupiter.api.Test;
import org.junit.Test;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertSame; import static org.junit.jupiter.api.Assertions.assertSame;
public class ExtendedPatientTest { public class ExtendedPatientTest {