|
37 | 37 | import java.util.List; |
38 | 38 | import java.util.stream.Collectors; |
39 | 39 |
|
| 40 | +import de.symeda.sormas.api.contact.FollowUpStatus; |
40 | 41 | import org.apache.commons.lang3.StringUtils; |
41 | 42 | import org.apache.commons.lang3.time.DateUtils; |
42 | 43 | import org.junit.Assert; |
@@ -203,6 +204,77 @@ public void testUpdateContactStatus() { |
203 | 204 | assertEquals(ContactStatus.CONVERTED, contact.getContactStatus()); |
204 | 205 | } |
205 | 206 |
|
| 207 | + @Test |
| 208 | + public void testContactFollowUpStatusCanceledWhenContactDropped(){ |
| 209 | + RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility"); |
| 210 | + UserDto user = creator |
| 211 | + .createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR); |
| 212 | + PersonDto cazePerson = creator.createPerson("Case", "Person"); |
| 213 | + CaseDataDto caze = creator.createCase( |
| 214 | + user.toReference(), |
| 215 | + cazePerson.toReference(), |
| 216 | + Disease.EVD, |
| 217 | + CaseClassification.PROBABLE, |
| 218 | + InvestigationStatus.PENDING, |
| 219 | + new Date(), |
| 220 | + rdcf); |
| 221 | + PersonDto contactPerson = creator.createPerson("Contact", "Person"); |
| 222 | + Date contactDate = new Date(); |
| 223 | + ContactDto contact = |
| 224 | + creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, contactDate, contactDate, null); |
| 225 | + |
| 226 | + assertEquals(ContactStatus.ACTIVE, contact.getContactStatus()); |
| 227 | + assertNull(contact.getResultingCase()); |
| 228 | + |
| 229 | + contact.setContactClassification(ContactClassification.CONFIRMED); |
| 230 | + contact.setContactStatus(ContactStatus.DROPPED); |
| 231 | + contact = getContactFacade().saveContact(contact); |
| 232 | + assertEquals(ContactClassification.CONFIRMED, contact.getContactClassification()); |
| 233 | + assertEquals(ContactStatus.DROPPED, contact.getContactStatus()); |
| 234 | + assertEquals(FollowUpStatus.CANCELED, contact.getFollowUpStatus()); |
| 235 | + } |
| 236 | + |
| 237 | + @Test |
| 238 | + public void testContactFollowUpStatusCanceledWhenContactConvertedToCase(){ |
| 239 | + RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility"); |
| 240 | + UserDto user = creator |
| 241 | + .createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR); |
| 242 | + PersonDto cazePerson = creator.createPerson("Case", "Person"); |
| 243 | + CaseDataDto caze = creator.createCase( |
| 244 | + user.toReference(), |
| 245 | + cazePerson.toReference(), |
| 246 | + Disease.EVD, |
| 247 | + CaseClassification.PROBABLE, |
| 248 | + InvestigationStatus.PENDING, |
| 249 | + new Date(), |
| 250 | + rdcf); |
| 251 | + PersonDto contactPerson = creator.createPerson("Contact", "Person"); |
| 252 | + |
| 253 | + Date contactDate = new Date(); |
| 254 | + ContactDto contact = |
| 255 | + creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, contactDate, contactDate, null); |
| 256 | + |
| 257 | + assertEquals(ContactStatus.ACTIVE, contact.getContactStatus()); |
| 258 | + assertNull(contact.getResultingCase()); |
| 259 | + |
| 260 | + contact.setContactClassification(ContactClassification.CONFIRMED); |
| 261 | + contact = getContactFacade().saveContact(contact); |
| 262 | + |
| 263 | + final CaseDataDto resultingCase = creator.createCase( |
| 264 | + user.toReference(), |
| 265 | + contactPerson.toReference(), |
| 266 | + Disease.EVD, |
| 267 | + CaseClassification.PROBABLE, |
| 268 | + InvestigationStatus.PENDING, |
| 269 | + new Date(), |
| 270 | + rdcf); |
| 271 | + contact.setResultingCase(resultingCase.toReference()); |
| 272 | + contact = getContactFacade().saveContact(contact); |
| 273 | + assertEquals(ContactClassification.CONFIRMED, contact.getContactClassification()); |
| 274 | + assertEquals(ContactStatus.CONVERTED, contact.getContactStatus()); |
| 275 | + assertEquals(FollowUpStatus.CANCELED, contact.getFollowUpStatus()); |
| 276 | + } |
| 277 | + |
206 | 278 | @Test |
207 | 279 | public void testGenerateContactFollowUpTasks() { |
208 | 280 |
|
|
0 commit comments