Merge branch 'gg_20201105-remove-person-references' of github.com:jamesagnew/hapi-fhir into gg_20201105-remove-person-references
This commit is contained in:
commit
176f7f0412
|
@ -7,6 +7,8 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||||
import ca.uhn.test.concurrency.PointcutLatch;
|
import ca.uhn.test.concurrency.PointcutLatch;
|
||||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||||
import org.hl7.fhir.r4.model.IdType;
|
import org.hl7.fhir.r4.model.IdType;
|
||||||
|
import org.hl7.fhir.r4.model.Medication;
|
||||||
|
import org.hl7.fhir.r4.model.Organization;
|
||||||
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;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
@ -23,10 +25,16 @@ import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
public class EmpiProviderBatchR4Test extends BaseLinkR4Test {
|
public class EmpiProviderBatchR4Test extends BaseLinkR4Test {
|
||||||
|
|
||||||
|
public static final String ORGANIZATION_DUMMY = "Organization/dummy";
|
||||||
protected Practitioner myPractitioner;
|
protected Practitioner myPractitioner;
|
||||||
protected StringType myPractitionerId;
|
protected StringType myPractitionerId;
|
||||||
protected IAnyResource myGoldenPractitier;
|
protected IAnyResource myGoldenPractitioner;
|
||||||
protected StringType myGoldenPractitionerId;
|
protected StringType myGoldenPractitionerId;
|
||||||
|
protected Medication myMedication;
|
||||||
|
protected StringType myMedicationId;
|
||||||
|
protected IAnyResource myGoldenMedication;
|
||||||
|
protected StringType myGoldenMedicationId;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
IInterceptorService myInterceptorService;
|
IInterceptorService myInterceptorService;
|
||||||
|
@ -38,8 +46,19 @@ public class EmpiProviderBatchR4Test extends BaseLinkR4Test {
|
||||||
super.before();
|
super.before();
|
||||||
myPractitioner = createPractitionerAndUpdateLinks(buildPractitionerWithNameAndId("some_pract", "some_pract_id"));
|
myPractitioner = createPractitionerAndUpdateLinks(buildPractitionerWithNameAndId("some_pract", "some_pract_id"));
|
||||||
myPractitionerId = new StringType(myPractitioner.getIdElement().getValue());
|
myPractitionerId = new StringType(myPractitioner.getIdElement().getValue());
|
||||||
myGoldenPractitier = getGoldenResourceFromTargetResource(myPractitioner);
|
myGoldenPractitioner = getGoldenResourceFromTargetResource(myPractitioner);
|
||||||
myGoldenPractitionerId = new StringType(myGoldenPractitier.getIdElement().getValue());
|
myGoldenPractitionerId = new StringType(myGoldenPractitioner.getIdElement().getValue());
|
||||||
|
|
||||||
|
Organization dummyOrganization = new Organization();
|
||||||
|
dummyOrganization.setId(ORGANIZATION_DUMMY);
|
||||||
|
myOrganizationDao.update(dummyOrganization);
|
||||||
|
|
||||||
|
myMedication = createMedicationAndUpdateLinks(buildMedication(ORGANIZATION_DUMMY));
|
||||||
|
myMedicationId = new StringType(myMedication.getIdElement().getValue());
|
||||||
|
myGoldenMedication = getGoldenResourceFromTargetResource(myMedication);
|
||||||
|
myGoldenMedicationId = new StringType(myGoldenMedication.getIdElement().getValue());
|
||||||
|
|
||||||
|
|
||||||
myInterceptorService.registerAnonymousInterceptor(Pointcut.EMPI_AFTER_PERSISTED_RESOURCE_CHECKED, afterEmpiLatch);
|
myInterceptorService.registerAnonymousInterceptor(Pointcut.EMPI_AFTER_PERSISTED_RESOURCE_CHECKED, afterEmpiLatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +68,15 @@ public class EmpiProviderBatchR4Test extends BaseLinkR4Test {
|
||||||
super.after();
|
super.after();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBatchRunOnAllMedications() throws InterruptedException {
|
||||||
|
StringType criteria = null;
|
||||||
|
myEmpiProviderR4.clearEmpiLinks(null, myRequestDetails);
|
||||||
|
|
||||||
|
afterEmpiLatch.runWithExpectedCount(1, () -> myEmpiProviderR4.empiBatchOnAllTargets(new StringType("Medication"), criteria, null));
|
||||||
|
assertLinkCount(1);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBatchRunOnAllPractitioners() throws InterruptedException {
|
public void testBatchRunOnAllPractitioners() throws InterruptedException {
|
||||||
StringType criteria = null;
|
StringType criteria = null;
|
||||||
|
@ -106,7 +134,7 @@ public class EmpiProviderBatchR4Test extends BaseLinkR4Test {
|
||||||
StringType criteria = new StringType("");
|
StringType criteria = new StringType("");
|
||||||
myEmpiProviderR4.clearEmpiLinks(null, myRequestDetails);
|
myEmpiProviderR4.clearEmpiLinks(null, myRequestDetails);
|
||||||
afterEmpiLatch.runWithExpectedCount(2, () -> {
|
afterEmpiLatch.runWithExpectedCount(2, () -> {
|
||||||
myEmpiProviderR4.empiBatchOnAllTargets(criteria, null);
|
myEmpiProviderR4.empiBatchOnAllTargets(null, criteria, null);
|
||||||
});
|
});
|
||||||
assertLinkCount(2);
|
assertLinkCount(2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,17 +217,27 @@ public class EmpiProviderR4 extends BaseEmpiProvider {
|
||||||
})
|
})
|
||||||
public Parameters empiBatchOnAllTargets(
|
public Parameters empiBatchOnAllTargets(
|
||||||
//TODO GGG MDM: also have to take it an optional resourceType here, to clarify which resources should have MDM run on them.
|
//TODO GGG MDM: also have to take it an optional resourceType here, to clarify which resources should have MDM run on them.
|
||||||
|
@OperationParam(name= ProviderConstants.MDM_BATCH_RUN_RESOURCE_TYPE, min = 0 , max = 1) StringType theResourceType,
|
||||||
@OperationParam(name= ProviderConstants.MDM_BATCH_RUN_CRITERIA,min = 0 , max = 1) StringType theCriteria,
|
@OperationParam(name= ProviderConstants.MDM_BATCH_RUN_CRITERIA,min = 0 , max = 1) StringType theCriteria,
|
||||||
ServletRequestDetails theRequestDetails) {
|
ServletRequestDetails theRequestDetails) {
|
||||||
String criteria = convertCriteriaToString(theCriteria);
|
String criteria = convertStringTypeToString(theCriteria);
|
||||||
long submittedCount = myMdmSubmitSvc.submitAllTargetTypesToEmpi(criteria);
|
String resourceType = convertStringTypeToString(theResourceType);
|
||||||
|
|
||||||
|
long submittedCount;
|
||||||
|
if (resourceType != null) {
|
||||||
|
submittedCount = myMdmSubmitSvc.submitTargetTypeToEmpi(resourceType, criteria);
|
||||||
|
} else {
|
||||||
|
submittedCount = myMdmSubmitSvc.submitAllTargetTypesToEmpi(criteria);
|
||||||
|
|
||||||
|
}
|
||||||
return buildMdmOutParametersWithCount(submittedCount);
|
return buildMdmOutParametersWithCount(submittedCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String convertCriteriaToString(StringType theCriteria) {
|
private String convertStringTypeToString(StringType theCriteria) {
|
||||||
return theCriteria == null ? null : theCriteria.getValueAsString();
|
return theCriteria == null ? null : theCriteria.getValueAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Operation(name = ProviderConstants.OPERATION_MDM_SUBMIT, idempotent = false, type = Patient.class, returnParameters = {
|
@Operation(name = ProviderConstants.OPERATION_MDM_SUBMIT, idempotent = false, type = Patient.class, returnParameters = {
|
||||||
@OperationParam(name = ProviderConstants.OPERATION_MDM_BATCH_RUN_OUT_PARAM_SUBMIT_COUNT, type = IntegerType.class)
|
@OperationParam(name = ProviderConstants.OPERATION_MDM_BATCH_RUN_OUT_PARAM_SUBMIT_COUNT, type = IntegerType.class)
|
||||||
})
|
})
|
||||||
|
@ -244,7 +254,7 @@ public class EmpiProviderR4 extends BaseEmpiProvider {
|
||||||
public Parameters empiBatchPatientType(
|
public Parameters empiBatchPatientType(
|
||||||
@OperationParam(name = ProviderConstants.MDM_BATCH_RUN_CRITERIA) StringType theCriteria,
|
@OperationParam(name = ProviderConstants.MDM_BATCH_RUN_CRITERIA) StringType theCriteria,
|
||||||
RequestDetails theRequest) {
|
RequestDetails theRequest) {
|
||||||
String criteria = convertCriteriaToString(theCriteria);
|
String criteria = convertStringTypeToString(theCriteria);
|
||||||
long submittedCount = myMdmSubmitSvc.submitPatientTypeToMdm(criteria);
|
long submittedCount = myMdmSubmitSvc.submitPatientTypeToMdm(criteria);
|
||||||
return buildMdmOutParametersWithCount(submittedCount);
|
return buildMdmOutParametersWithCount(submittedCount);
|
||||||
}
|
}
|
||||||
|
@ -265,7 +275,7 @@ public class EmpiProviderR4 extends BaseEmpiProvider {
|
||||||
public Parameters empiBatchPractitionerType(
|
public Parameters empiBatchPractitionerType(
|
||||||
@OperationParam(name = ProviderConstants.MDM_BATCH_RUN_CRITERIA) StringType theCriteria,
|
@OperationParam(name = ProviderConstants.MDM_BATCH_RUN_CRITERIA) StringType theCriteria,
|
||||||
RequestDetails theRequest) {
|
RequestDetails theRequest) {
|
||||||
String criteria = convertCriteriaToString(theCriteria);
|
String criteria = convertStringTypeToString(theCriteria);
|
||||||
long submittedCount = myMdmSubmitSvc.submitPractitionerTypeToMdm(criteria);
|
long submittedCount = myMdmSubmitSvc.submitPractitionerTypeToMdm(criteria);
|
||||||
return buildMdmOutParametersWithCount(submittedCount);
|
return buildMdmOutParametersWithCount(submittedCount);
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,4 +92,5 @@ public class ProviderConstants {
|
||||||
public static final String MDM_BATCH_RUN_CRITERIA = "criteria" ;
|
public static final String MDM_BATCH_RUN_CRITERIA = "criteria" ;
|
||||||
public static final String OPERATION_MDM_BATCH_RUN_OUT_PARAM_SUBMIT_COUNT = "submitted" ;
|
public static final String OPERATION_MDM_BATCH_RUN_OUT_PARAM_SUBMIT_COUNT = "submitted" ;
|
||||||
public static final String OPERATION_MDM_CLEAR_OUT_PARAM_DELETED_COUNT = "deleted";
|
public static final String OPERATION_MDM_CLEAR_OUT_PARAM_DELETED_COUNT = "deleted";
|
||||||
|
public static final String MDM_BATCH_RUN_RESOURCE_TYPE = "resourceType";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue