use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method savePatientIdentifierType_shouldUpdateExistingType.
/**
* @see PatientService#savePatientIdentifierType(PatientIdentifierType)
*/
@Test
public void savePatientIdentifierType_shouldUpdateExistingType() throws Exception {
PatientIdentifierType type = patientService.getPatientIdentifierType(1);
type.setName("SOME NEW NAME");
patientService.savePatientIdentifierType(type);
PatientIdentifierType newerPatientIdentifierType = patientService.getPatientIdentifierType(1);
assertEquals("SOME NEW NAME", newerPatientIdentifierType.getName());
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientDAOTest method getPatientIdentifierTypes_shouldReturnNonRetiredPatientIdentifierTypesThatAreNotRequired.
/**
* @see PatientDAO#getPatientIdentifierTypes(String, String, Boolean, Boolean)
*/
@Test
public void getPatientIdentifierTypes_shouldReturnNonRetiredPatientIdentifierTypesThatAreNotRequired() {
PatientIdentifierType nonRetiredNonRequired1 = dao.getPatientIdentifierType(1);
PatientIdentifierType nonRetiredNonRequired2 = dao.getPatientIdentifierType(2);
PatientIdentifierType nonRetiredNonRequired3 = dao.getPatientIdentifierType(5);
List<PatientIdentifierType> patientIdentifierTypes = dao.getPatientIdentifierTypes(null, null, false, null);
Assert.assertEquals(patientIdentifierTypes.size(), 3);
Assert.assertTrue(patientIdentifierTypes.contains(nonRetiredNonRequired1));
Assert.assertTrue(patientIdentifierTypes.contains(nonRetiredNonRequired2));
Assert.assertTrue(patientIdentifierTypes.contains(nonRetiredNonRequired3));
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method mergePatients_shouldNotCopyOverDuplicatePatientIdentifiers.
/**
* @see PatientService#mergePatients(Patient,Patient)
*/
@Test
public void mergePatients_shouldNotCopyOverDuplicatePatientIdentifiers() throws Exception {
List<Location> locations = Context.getLocationService().getAllLocations();
Assert.assertTrue(CollectionUtils.isNotEmpty(locations));
// check if we have patient identifiers already
PatientIdentifierType patientIdentifierType = Context.getPatientService().getPatientIdentifierType(5);
Assert.assertNotNull(patientIdentifierType);
// retrieve preferred patient and set gender
Patient preferred = patientService.getPatient(999);
// create new identifier for the preferred patient
PatientIdentifier preferredIdentifier = new PatientIdentifier();
preferredIdentifier.setIdentifier("9999-4");
preferredIdentifier.setIdentifierType(patientIdentifierType);
preferredIdentifier.setLocation(locations.get(0));
preferred.addIdentifier(preferredIdentifier);
preferred.addName(new PersonName("givenName", "middleName", "familyName"));
patientService.savePatient(preferred);
// merge with not preferred
Patient notPreferred = patientService.getPatient(7);
voidOrders(Collections.singleton(notPreferred));
// create identifier with the same values for the non preferred patient
PatientIdentifier nonPreferredIdentifier = new PatientIdentifier();
nonPreferredIdentifier.setIdentifier("9999-4");
nonPreferredIdentifier.setIdentifierType(patientIdentifierType);
nonPreferredIdentifier.setLocation(locations.get(0));
notPreferred.addIdentifier(nonPreferredIdentifier);
patientService.savePatient(notPreferred);
PersonMergeLog audit = mergeAndRetrieveAudit(preferred, notPreferred);
// should not copy the duplicate identifier to the winner
Assert.assertEquals(notPreferred.getIdentifiers().size() - 1, audit.getPersonMergeLogData().getCreatedIdentifiers().size());
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method savePatientIdentifierType_shouldThrowErrorWhenTryingToSaveAPatientIdentifierTypeWhilePatientIdentifierTypesAreLocked.
@Test(expected = PatientIdentifierTypeLockedException.class)
public void savePatientIdentifierType_shouldThrowErrorWhenTryingToSaveAPatientIdentifierTypeWhilePatientIdentifierTypesAreLocked() throws Exception {
PatientService ps = Context.getPatientService();
createPatientIdentifierTypeLockedGPAndSetValue("true");
PatientIdentifierType pit = ps.getPatientIdentifierType(1);
pit.setDescription("test");
ps.savePatientIdentifierType(pit);
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method unretirePatientIdentifierType_shouldReturnUnretiredPatientIdentifierType.
/**
* @see PatientService#unretirePatientIdentifierType(PatientIdentifierType)
*/
@Test
public void unretirePatientIdentifierType_shouldReturnUnretiredPatientIdentifierType() 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