|
31 | 31 | import org.junit.jupiter.api.Test;
|
32 | 32 |
|
33 | 33 | import de.symeda.sormas.api.Disease;
|
| 34 | +import de.symeda.sormas.api.caze.CaseCriteria; |
34 | 35 | import de.symeda.sormas.api.caze.CaseDataDto;
|
35 | 36 | import de.symeda.sormas.api.externalmessage.ExternalMessageDto;
|
36 | 37 | import de.symeda.sormas.api.externalmessage.ExternalMessageStatus;
|
|
46 | 47 | import de.symeda.sormas.api.sample.PathogenTestDto;
|
47 | 48 | import de.symeda.sormas.api.sample.PathogenTestResultType;
|
48 | 49 | import de.symeda.sormas.api.sample.PathogenTestType;
|
| 50 | +import de.symeda.sormas.api.sample.SampleCriteria; |
49 | 51 | import de.symeda.sormas.api.sample.SampleDto;
|
50 | 52 | import de.symeda.sormas.api.sample.SampleMaterial;
|
51 | 53 | import de.symeda.sormas.api.sample.SamplePurpose;
|
@@ -213,6 +215,42 @@ public void testProcessWithExistingPersonAndCase() throws ExecutionException, In
|
213 | 215 | assertThat(samples, hasSize(2));
|
214 | 216 | }
|
215 | 217 |
|
| 218 | + /** |
| 219 | + * External message with sample date in the threshold period should generate a new sample to the existing case |
| 220 | + * @throws ExecutionException |
| 221 | + * @throws InterruptedException |
| 222 | + */ |
| 223 | + @Test |
| 224 | + public void testThresholdAgainstSampleDate() throws ExecutionException, InterruptedException { |
| 225 | + ExternalMessageDto externalMessage = createExternalMessage(e -> { |
| 226 | + e.getSampleReports().get(0).setSampleDateTime(DateHelper.subtractDays(new Date(), 10)); |
| 227 | + }); |
| 228 | + |
| 229 | + PersonDto person = |
| 230 | + creator.createPerson(externalMessage.getPersonFirstName(), externalMessage.getPersonLastName(), externalMessage.getPersonSex(), p -> { |
| 231 | + p.setNationalHealthId(externalMessage.getPersonNationalHealthId()); |
| 232 | + }); |
| 233 | + |
| 234 | + CaseDataDto caze = creator.createCase(reportingUser.toReference(), person.toReference(), rdcf, c -> { |
| 235 | + c.setDisease(externalMessage.getDisease()); |
| 236 | + c.setReportDate(DateHelper.subtractDays(new Date(), 15)); |
| 237 | + }); |
| 238 | + creator.createSample(caze.toReference(), reportingUser.toReference(), rdcf.facility, s -> { |
| 239 | + s.setSampleDateTime(DateHelper.subtractDays(new Date(), 15)); |
| 240 | + }); |
| 241 | + |
| 242 | + // set the threshold |
| 243 | + creator.updateDiseaseConfiguration(externalMessage.getDisease(), true, true, true, true, null, 10); |
| 244 | + getBean(DiseaseConfigurationFacadeEjb.DiseaseConfigurationFacadeEjbLocal.class).loadData(); |
| 245 | + |
| 246 | + ProcessingResult<ExternalMessageProcessingResult> result = runFlow(externalMessage); |
| 247 | + assertThat(result.getStatus(), is(DONE)); |
| 248 | + assertThat(externalMessage.getStatus(), is(ExternalMessageStatus.PROCESSED)); |
| 249 | + |
| 250 | + assertThat(getCaseFacade().count(new CaseCriteria().person(caze.getPerson())), is(1L)); |
| 251 | + assertThat(getSampleFacade().count(new SampleCriteria().caze(caze.toReference())), is(2L)); |
| 252 | + } |
| 253 | + |
216 | 254 | @Test
|
217 | 255 | public void testProcessWithExistingPersonAndCaseWithBySampleDate() throws ExecutionException, InterruptedException {
|
218 | 256 | ExternalMessageDto externalMessage = createExternalMessage(null);
|
|
0 commit comments