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
public int runEmpiOnAllTargetTypes(String theCriteria) {
int submittedCount = 0;
submittedCount += runEmpiOnTargetType("Patient", theCriteria);
submittedCount += runEmpiOnTargetType("Practitioner", theCriteria);
submittedCount += runEmpiOnPatientType(theCriteria);
submittedCount += runEmpiOnPractitionerType(theCriteria);
return submittedCount;
}
@ -69,7 +69,6 @@ public class EmpiBatchSvcImpl implements IEmpiBatchService {
while (query.hasNext()) {
pidsToSubmit.add(query.next());
if (pidsToSubmit.size() == QUEUE_ADDING_PAGE_SIZE || !query.hasNext()) {
//TODO GGG ask ken how this works.
total = loadResourcesAndSubmitToEmpi(total, mySearchBuilder, pidsToSubmit, resourceToBeSubmitted);
resourceToBeSubmitted.clear();
}
@ -81,6 +80,7 @@ public class EmpiBatchSvcImpl implements IEmpiBatchService {
}
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);
theResourceToBeSubmitted
.forEach(resource -> myEmpiQueueSubmitterSvc.manuallySubmitResourceToEmpi(resource));
@ -113,13 +113,13 @@ public class EmpiBatchSvcImpl implements IEmpiBatchService {
@Override
@Transactional
public int runEmpiOnTargetPractitioner(IIdType theId) {
return runEmpiOnTarget(theId, "practitioner");
return runEmpiOnTarget(theId, "Practitioner");
}
@Override
@Transactional
public int runEmpiOnTargetPatient(IIdType theId) {
return runEmpiOnTarget(theId, "patient");
return runEmpiOnTarget(theId, "Patient");
}
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.Pointcut;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
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.Practitioner;
import org.hl7.fhir.r4.model.StringType;
@ -54,6 +56,23 @@ public class EmpiProviderBatchR4Test extends BaseLinkR4Test {
afterEmpiLatch.runWithExpectedCount(1, () -> myEmpiProviderR4.empiBatchPractitionerType(criteria, null));
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
public void testBatchRunOnAllPatients() {
@ -64,6 +83,24 @@ public class EmpiProviderBatchR4Test extends BaseLinkR4Test {
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
public void testBatchRunOnAllTypes() {
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.Reference;
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.Assert.assertSame;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertSame;
public class ExtendedPatientTest {

View File

@ -1,15 +1,15 @@
package ca.uhn.fhir.parser;
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.CodeType;
import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Reference;
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.Assert.assertSame;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertSame;
public class ExtendedPatientTest {