use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method getPatientIdentifierTypeByUuid_shouldFetchPatientIdentifierTypeWithGivenUuid.
/**
* @see PatientService#getPatientIdentifierTypeByUuid(String)
*/
@Test
public void getPatientIdentifierTypeByUuid_shouldFetchPatientIdentifierTypeWithGivenUuid() throws Exception {
PatientIdentifierType identifierType = Context.getPatientService().getPatientIdentifierTypeByUuid("1a339fe9-38bc-4ab3-b180-320988c0b968");
Assert.assertNotNull(identifierType);
Assert.assertTrue(identifierType.getClass().isAssignableFrom(PatientIdentifierType.class));
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method getAllPatientIdentifierTypes_shouldFetchPatientIdentifierTypesIncludingRetiredWhenIncludeRetiredIsTrue.
/**
* @see PatientService#getAllPatientIdentifierTypes(null)
*/
@Test
public void getAllPatientIdentifierTypes_shouldFetchPatientIdentifierTypesIncludingRetiredWhenIncludeRetiredIsTrue() throws Exception {
Collection<PatientIdentifierType> types = Context.getPatientService().getAllPatientIdentifierTypes(true);
boolean atLeastOneRetired = false;
for (PatientIdentifierType type : types) {
if (type.getRetired()) {
atLeastOneRetired = true;
break;
}
}
Assert.assertTrue("There should be at least one retired patient identifier type", atLeastOneRetired);
Assert.assertEquals("Should be exactly four patient identifier types", 4, types.size());
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method getPatients_shouldSupportSimpleRegex.
/**
* @see PatientService#getPatients(String, String, java.util.List, boolean)
*/
@Test
public void getPatients_shouldSupportSimpleRegex() throws Exception {
Context.getAdministrationService().saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_IDENTIFIER_REGEX, "^0*@SEARCH@([A-Z]+-[0-9])?$"));
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("1234-4").size());
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method isIdentifierInUseByAnotherPatient_shouldReturnTrueIfInUseAndIdTypeUniquenessIsNull.
/**
* @see PatientService#isIdentifierInUseByAnotherPatient(PatientIdentifier)
*/
@Test
public void isIdentifierInUseByAnotherPatient_shouldReturnTrueIfInUseAndIdTypeUniquenessIsNull() throws Exception {
PatientIdentifier duplicateId = patientService.getPatientIdentifier(1);
Assert.assertNotNull(duplicateId.getLocation());
PatientIdentifierType idType = duplicateId.getIdentifierType();
Assert.assertNull(idType.getUniquenessBehavior());
PatientIdentifier pi = new PatientIdentifier(duplicateId.getIdentifier(), idType, duplicateId.getLocation());
Assert.assertTrue(patientService.isIdentifierInUseByAnotherPatient(pi));
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method savePatientIdentifier_shouldCreateNewPatientIndentifier.
@Test
public void savePatientIdentifier_shouldCreateNewPatientIndentifier() throws Exception {
PatientIdentifier patientIdentifier = new PatientIdentifier("677-56-6666", new PatientIdentifierType(4), new Location(1));
Patient associatedPatient = patientService.getPatient(2);
patientIdentifier.setPatient(associatedPatient);
PatientIdentifier createdPatientIdentifier = patientService.savePatientIdentifier(patientIdentifier);
Assert.assertNotNull(createdPatientIdentifier);
Assert.assertNotNull(createdPatientIdentifier.getPatientIdentifierId());
}
Aggregations