use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method getPatientIdentifierTypes_shouldOrderAsDefaultComparator.
/**
* @see PatientService#getPatientIdentifierTypes(String,String,Boolean,Boolean)
*/
@Test
public void getPatientIdentifierTypes_shouldOrderAsDefaultComparator() throws Exception {
List<PatientIdentifierType> list = patientService.getPatientIdentifierTypes(null, null, false, null);
List<PatientIdentifierType> sortedList = new ArrayList<>(list);
sortedList.sort(new PatientIdentifierTypeDefaultComparator());
Assert.assertEquals(sortedList, list);
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method getAllPatientIdentifierTypes_shouldFetchAllNonRetiredPatientIdentifierTypes.
/**
* @see PatientService#getAllPatientIdentifierTypes()
*/
@Test
public void getAllPatientIdentifierTypes_shouldFetchAllNonRetiredPatientIdentifierTypes() throws Exception {
Collection<PatientIdentifierType> types = Context.getPatientService().getAllPatientIdentifierTypes();
Assert.assertNotNull("Should not return null", types);
for (PatientIdentifierType type : types) {
if (type.getRetired()) {
Assert.fail("Should not return retired patient identifier types");
}
}
Assert.assertEquals("Should be exactly three patient identifier types in the dataset", 3, types.size());
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method savePatientIdentifierType_shouldUpdateExistingPatientIdentifierType.
/**
* @see PatientService#savePatientIdentifierType(PatientIdentifierType)
*/
@Test
public void savePatientIdentifierType_shouldUpdateExistingPatientIdentifierType() throws Exception {
PatientIdentifierType identifierType = Context.getPatientService().getAllPatientIdentifierTypes().get(0);
Assert.assertNotNull(identifierType);
Assert.assertNotNull(identifierType.getPatientIdentifierTypeId());
Assert.assertEquals(2, identifierType.getPatientIdentifierTypeId().intValue());
Assert.assertNotSame("test", identifierType.getName());
// Change existing patient identifier
identifierType.setName("test");
identifierType.setDescription("test description");
identifierType.setRequired(false);
patientService.savePatientIdentifierType(identifierType);
PatientIdentifierType savedIdentifierType = patientService.getPatientIdentifierType(2);
assertNotNull(savedIdentifierType);
Assert.assertEquals("test", identifierType.getName());
assertTrue(savedIdentifierType.equals(identifierType));
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method getPatients_shouldSupportPatternUsingLastDigitAsCheckDigit.
/**
* @see PatientService#getPatients(String, String, java.util.List, boolean)
*/
@Test
public void getPatients_shouldSupportPatternUsingLastDigitAsCheckDigit() throws Exception {
Context.getAdministrationService().saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_IDENTIFIER_SEARCH_PATTERN, "@SEARCH@,0@SEARCH@,@SEARCH-1@-@CHECKDIGIT@,0@SEARCH-1@-@CHECKDIGIT@"));
// "^(0*@SEARCH-1@-@CHECKDIGIT@)$"));
PatientIdentifier identifier = new PatientIdentifier("1234-4", new PatientIdentifierType(1), new Location(1));
identifier.setCreator(new User(1));
identifier.setDateCreated(new Date());
Patient patient = Context.getPatientService().getPatient(2);
patient.addIdentifier(identifier);
Context.getPatientService().savePatient(patient);
updateSearchIndex();
assertEquals(1, Context.getPatientService().getPatients("12344").size());
assertEquals(1, Context.getPatientService().getPatients("1234-4").size());
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method savePatientIdentifierType_shouldCreateNewType.
/**
* @see PatientService#savePatientIdentifierType(PatientIdentifierType)
*/
@Test
public void savePatientIdentifierType_shouldCreateNewType() throws Exception {
PatientIdentifierType patientIdentifierType = new PatientIdentifierType();
patientIdentifierType.setName("testing");
patientIdentifierType.setDescription("desc");
patientIdentifierType.setRequired(false);
patientService.savePatientIdentifierType(patientIdentifierType);
PatientIdentifierType newPatientIdentifierType = patientService.getPatientIdentifierType(patientIdentifierType.getPatientIdentifierTypeId());
assertNotNull(newPatientIdentifierType);
}
Aggregations