use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method retirePatientIdentifierType_shouldThrowAPIExceptionWhenNullReasonIsPassed.
@Test(expected = APIException.class)
public void retirePatientIdentifierType_shouldThrowAPIExceptionWhenNullReasonIsPassed() throws Exception {
PatientService ps = Context.getPatientService();
PatientIdentifierType pit = ps.getPatientIdentifierType(1);
ps.retirePatientIdentifierType(pit, null);
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method shouldGetPatientsByIdentifierAndIdentifierType.
/**
* Test the PatientService.getPatients(String, String, List) method with both an identifier and
* an identifiertype
*
* @throws Exception
*/
@Test
@SkipBaseSetup
public void shouldGetPatientsByIdentifierAndIdentifierType() throws Exception {
initializeInMemoryDatabase();
executeDataSet(FIND_PATIENTS_XML);
authenticate();
updateSearchIndex();
List<PatientIdentifierType> types = new ArrayList<>();
types.add(new PatientIdentifierType(1));
// make sure we get back only one patient
List<Patient> patients = patientService.getPatients("1234", null, types, false);
assertEquals(1, patients.size());
// make sure we get back only one patient
patients = patientService.getPatients("1234", null, null, false);
assertEquals(1, patients.size());
// make sure we can search a padded identifier
patients = patientService.getPatients("00000001234", null, null, false);
assertEquals(1, patients.size());
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method savePatient_shouldNotThrowANonUniqueObjectExceptionWhenCalledWithAHandConstructedPatient.
/**
* Regression test for http://dev.openmrs.org/ticket/1375
*
* @see PatientService#savePatient(Patient)
*/
@Test
public void savePatient_shouldNotThrowANonUniqueObjectExceptionWhenCalledWithAHandConstructedPatient() throws Exception {
Patient patient = new Patient();
patient.setGender("M");
patient.setPatientId(2);
// patient.setCreator(new User(1));
// patient.setDateCreated date_created="2005-09-22 00:00:00.0"
// changed_by="1" date_changed="2008-08-18 12:29:59.0"
patient.addName(new PersonName("This", "Isa", "Test"));
PatientIdentifier patientIdentifier = new PatientIdentifier("101-6", new PatientIdentifierType(1), new Location(1));
patientIdentifier.setPreferred(true);
patient.addIdentifier(patientIdentifier);
Context.getPatientService().savePatient(patient);
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method isIdentifierInUseByAnotherPatient_shouldReturnTrueIfInUseAndIdTypeUniquenessIsSetToUnique.
/**
* @see PatientService#isIdentifierInUseByAnotherPatient(PatientIdentifier)
*/
@Test
public void isIdentifierInUseByAnotherPatient_shouldReturnTrueIfInUseAndIdTypeUniquenessIsSetToUnique() throws Exception {
PatientIdentifier duplicateId = patientService.getPatientIdentifier(1);
Assert.assertNotNull(duplicateId.getLocation());
PatientIdentifierType idType = duplicateId.getIdentifierType();
idType.setUniquenessBehavior(UniquenessBehavior.UNIQUE);
patientService.savePatientIdentifierType(idType);
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 getPatientIdentifierTypes_shouldFetchPatientIdentifierTypesThatMatchGivenNameWithGivenFormat.
/**
* @see PatientService#getPatientIdentifierTypes(String,String,Boolean,Boolean)
*/
@Test
public void getPatientIdentifierTypes_shouldFetchPatientIdentifierTypesThatMatchGivenNameWithGivenFormat() throws Exception {
executeDataSet("org/openmrs/api/include/PatientServiceTest-createPatientIdentifierType.xml");
List<PatientIdentifierType> patientIdentifierTypes = Context.getPatientService().getPatientIdentifierTypes("Test OpenMRS Identification Number", "java.lang.Integer", null, null);
Assert.assertEquals(false, patientIdentifierTypes.isEmpty());
for (PatientIdentifierType patientIdentifierType : patientIdentifierTypes) {
Assert.assertEquals("Test OpenMRS Identification Number", patientIdentifierType.getName());
Assert.assertEquals("java.lang.Integer", patientIdentifierType.getFormat());
}
}
Aggregations