use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method getPatientIdentifierTypeByUuid_shouldReturnNullWhenPatientIdentifierTypeWithGivenUuidDoesNotExist.
/**
* @see PatientService#getPatientIdentifierTypeByUuid(String)
*/
@Test
public void getPatientIdentifierTypeByUuid_shouldReturnNullWhenPatientIdentifierTypeWithGivenUuidDoesNotExist() throws Exception {
PatientIdentifierType identifierType = Context.getPatientService().getPatientIdentifierTypeByUuid("thisuuiddoesnotexist");
Assert.assertNull(identifierType);
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method getPatientIdentifierTypes_shouldFetchRequiredPatientIdentifierTypesWhenGivenRequiredIsTrue.
/**
* @see PatientService#getPatientIdentifierTypes(String,String,Boolean,Boolean)
*/
@Test
public void getPatientIdentifierTypes_shouldFetchRequiredPatientIdentifierTypesWhenGivenRequiredIsTrue() throws Exception {
executeDataSet("org/openmrs/api/include/PatientServiceTest-createPatientIdentifierType.xml");
List<PatientIdentifierType> patientIdentifierTypes = Context.getPatientService().getPatientIdentifierTypes(null, null, true, null);
Assert.assertTrue(!patientIdentifierTypes.isEmpty());
Assert.assertEquals(1, patientIdentifierTypes.size());
for (PatientIdentifierType patientIdentifierType : patientIdentifierTypes) {
Assert.assertTrue(patientIdentifierType.getRequired());
}
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method retirePatientIdentifierType_shouldRetireAndSetReasonAndRetiredByAndDate.
@Test
public void retirePatientIdentifierType_shouldRetireAndSetReasonAndRetiredByAndDate() {
PatientService ps = Context.getPatientService();
PatientIdentifierType pit = ps.getPatientIdentifierType(1);
String reason = "moved away";
PatientIdentifierType result = ps.retirePatientIdentifierType(pit, reason);
assertTrue(result.getRetired());
assertEquals(result.getRetireReason(), reason);
assertEquals(result.getRetiredBy(), Context.getAuthenticatedUser());
Date today = new Date();
Date dateRetired = result.getDateRetired();
assertEquals(dateRetired.getDay(), today.getDay());
assertEquals(dateRetired.getMonth(), today.getMonth());
assertEquals(dateRetired.getYear(), today.getYear());
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method unretirePatientIdentifierType_shouldThrowErrorWhenTryingToUnretireAPatientIdentifierTypeWhilePatientIdentifierTypesAreLocked.
@Test(expected = PatientIdentifierTypeLockedException.class)
public void unretirePatientIdentifierType_shouldThrowErrorWhenTryingToUnretireAPatientIdentifierTypeWhilePatientIdentifierTypesAreLocked() throws Exception {
PatientService ps = Context.getPatientService();
createPatientIdentifierTypeLockedGPAndSetValue("true");
PatientIdentifierType pit = ps.getPatientIdentifierType(1);
ps.unretirePatientIdentifierType(pit);
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method unretirePatientIdentifierType_shouldUnretirePatientIdentifierType.
/**
* @see PatientService#unretirePatientIdentifierType(PatientIdentifierType)
*/
@Test
public void unretirePatientIdentifierType_shouldUnretirePatientIdentifierType() throws Exception {
PatientIdentifierType identifierType = Context.getPatientService().getPatientIdentifierType(4);
Assert.assertTrue(identifierType.getRetired());
Assert.assertNotNull(identifierType.getRetiredBy());
Assert.assertNotNull(identifierType.getRetireReason());
Assert.assertNotNull(identifierType.getDateRetired());
PatientIdentifierType unretiredIdentifierType = Context.getPatientService().unretirePatientIdentifierType(identifierType);
Assert.assertFalse(unretiredIdentifierType.getRetired());
Assert.assertNull(unretiredIdentifierType.getRetiredBy());
Assert.assertNull(unretiredIdentifierType.getRetireReason());
Assert.assertNull(unretiredIdentifierType.getDateRetired());
}
Aggregations