Finish tests in BatchSvcImplTest

This commit is contained in:
Tadgh 2020-11-16 15:45:50 -05:00
parent 869814606d
commit 799f6adecb
4 changed files with 38 additions and 10 deletions

View File

@ -85,6 +85,7 @@ abstract public class BaseEmpiR4Test extends BaseJpaR4Test {
.setValue("555-555-5555");
private static final String NAME_GIVEN_FRANK = "Frank";
protected static final String FRANK_ID = "ID.FRANK.789";
protected static final String DUMMY_ORG_ID = "Organization/mfr";
@Autowired
protected FhirContext myFhirContext;
@ -346,6 +347,11 @@ abstract public class BaseEmpiR4Test extends BaseJpaR4Test {
medication.setCode(codeableConcept);
return medication;
}
protected Medication buildMedicationWithDummyOrganization() {
return buildMedication(DUMMY_ORG_ID);
}
protected Medication createMedicationAndUpdateLinks(Medication theMedication) {
theMedication = createMedication(theMedication);
myEmpiMatchLinkSvc.updateEmpiLinksForEmpiTarget(theMedication, createContextForCreate("Medication"));
@ -512,4 +518,9 @@ abstract public class BaseEmpiR4Test extends BaseJpaR4Test {
});
}
protected DaoMethodOutcome createDummyOrganization() {
Organization org = new Organization();
org.setId(DUMMY_ORG_ID);
return myOrganizationDao.update(org);
}
}

View File

@ -58,9 +58,7 @@ public class EmpiProviderMatchR4Test extends BaseProviderR4Test {
@Test
public void testMedicationMatch() throws Exception {
Organization org = new Organization();
org.setId("Organization/mfr");
myOrganizationDao.update(org);
createDummyOrganization();
Medication medication = buildMedication("Organization/mfr");

View File

@ -46,12 +46,17 @@ class EmpiBatchSvcImplTest extends BaseEmpiR4Test {
createPractitioner(buildPractitionerWithNameAndId("test", "id"));
}
createDummyOrganization();
for(int i = 0; i< 10; i++) {
createMedication(buildMedicationWithDummyOrganization());
}
assertLinkCount(0);
//SUT
afterEmpiLatch.runWithExpectedCount(20, () -> myEmpiSubmitSvc.submitAllTargetTypesToEmpi(null));
afterEmpiLatch.runWithExpectedCount(30, () -> myEmpiSubmitSvc.submitAllTargetTypesToEmpi(null));
assertLinkCount(20);
assertLinkCount(30);
}
@Test
@ -69,6 +74,23 @@ class EmpiBatchSvcImplTest extends BaseEmpiR4Test {
assertLinkCount(10);
}
@Test
public void testEmpiBatchOnMedicationType() throws Exception {
createDummyOrganization();
for(int i = 0; i< 10; i++) {
createMedication(buildMedicationWithDummyOrganization());
}
assertLinkCount(0);
//SUT
afterEmpiLatch.runWithExpectedCount(10, () -> myEmpiSubmitSvc.submitTargetTypeToEmpi("Medication", null));
assertLinkCount(10);
}
@Test
public void testEmpiBatchOnPractitionerType() throws Exception {
@ -92,7 +114,7 @@ class EmpiBatchSvcImplTest extends BaseEmpiR4Test {
assertLinkCount(0);
//SUT
afterEmpiLatch.runWithExpectedCount(1, () -> myEmpiSubmitSvc.submitAllTargetTypesToEmpi("Patient?name=gary"));
afterEmpiLatch.runWithExpectedCount(1, () -> myEmpiSubmitSvc.submitTargetTypeToEmpi("Patient", "Patient?name=gary"));
assertLinkCount(1);
}

View File

@ -19,7 +19,6 @@ import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.r4.model.Enumerations;
import org.hl7.fhir.r4.model.HumanName;
import org.hl7.fhir.r4.model.Identifier;
import org.hl7.fhir.r4.model.Organization;
import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Practitioner;
import org.junit.jupiter.api.BeforeEach;
@ -80,9 +79,7 @@ public class EmpiMatchLinkSvcTest extends BaseEmpiR4Test {
@Test
public void testAddMedicationLinksToNewGoldenRecordMedicationIfNoneFound() {
Organization org = new Organization();
org.setId("Organization/mfr");
myOrganizationDao.update(org);
createDummyOrganization();
createMedicationAndUpdateLinks(buildMedication("Organization/mfr"));
assertLinkCount(1);