use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method shouldCreatePatient.
@Test
public void shouldCreatePatient() throws Exception {
executeDataSet(CREATE_PATIENT_XML);
Patient patient = new Patient();
PersonName pName = new PersonName();
pName.setGivenName("Tom");
pName.setMiddleName("E.");
pName.setFamilyName("Patient");
patient.addName(pName);
PersonAddress pAddress = new PersonAddress();
pAddress.setAddress1("123 My street");
pAddress.setAddress2("Apt 402");
pAddress.setCityVillage("Anywhere city");
pAddress.setCountry("Some Country");
Set<PersonAddress> pAddressList = patient.getAddresses();
pAddressList.add(pAddress);
patient.setAddresses(pAddressList);
patient.addAddress(pAddress);
// patient.removeAddress(pAddress);
patient.setBirthdateEstimated(true);
patient.setBirthdate(new Date());
patient.setBirthdateEstimated(true);
patient.setDeathDate(new Date());
patient.setCauseOfDeath(new Concept());
patient.setGender("male");
List<PatientIdentifierType> patientIdTypes = patientService.getAllPatientIdentifierTypes();
assertNotNull(patientIdTypes);
PatientIdentifier patientIdentifier = new PatientIdentifier();
patientIdentifier.setIdentifier("123-0");
patientIdentifier.setIdentifierType(patientIdTypes.get(0));
patientIdentifier.setLocation(new Location(1));
patientIdentifier.setPreferred(true);
Set<PatientIdentifier> patientIdentifiers = new LinkedHashSet<>();
patientIdentifiers.add(patientIdentifier);
patient.setIdentifiers(patientIdentifiers);
patientService.savePatient(patient);
Patient createdPatient = patientService.getPatient(patient.getPatientId());
assertNotNull(createdPatient);
assertNotNull(createdPatient.getPatientId());
Patient createdPatientById = patientService.getPatient(createdPatient.getPatientId());
assertNotNull(createdPatientById);
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method isIdentifierInUseByAnotherPatient_shouldIgnoreVoidedPatients.
/**
* Regression test for http://dev.openmrs.org/ticket/790
*
* @see PatientService#isIdentifierInUseByAnotherPatient(PatientIdentifier)
*/
@Test
public void isIdentifierInUseByAnotherPatient_shouldIgnoreVoidedPatients() throws Exception {
{
// patient 999 should be voided and have a non-voided identifier of
// XYZ
Patient p = patientService.getPatient(999);
Assert.assertNotNull(p);
Assert.assertTrue(p.getVoided());
boolean found = false;
for (PatientIdentifier id : p.getIdentifiers()) {
if (id.getIdentifier().equals("XYZ") && id.getIdentifierType().getId() == 2) {
found = true;
break;
}
}
Assert.assertTrue(found);
}
PatientIdentifierType pit = patientService.getPatientIdentifierType(2);
PatientIdentifier patientIdentifier = new PatientIdentifier("XYZ", pit, null);
Assert.assertFalse(patientService.isIdentifierInUseByAnotherPatient(patientIdentifier));
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method getPatientIdentifierTypes_shouldFetchNonRequiredPatientIdentifierTypesWhenGivenRequiredIsFalse.
/**
* @see PatientService#getPatientIdentifierTypes(String,String,Boolean,Boolean)
*/
@Test
public void getPatientIdentifierTypes_shouldFetchNonRequiredPatientIdentifierTypesWhenGivenRequiredIsFalse() throws Exception {
executeDataSet("org/openmrs/api/include/PatientServiceTest-createPatientIdentifierType.xml");
List<PatientIdentifierType> patientIdentifierTypes = Context.getPatientService().getPatientIdentifierTypes(null, null, false, null);
Assert.assertTrue(!patientIdentifierTypes.isEmpty());
for (PatientIdentifierType patientIdentifierType : patientIdentifierTypes) {
Assert.assertFalse(patientIdentifierType.getRequired());
}
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method getPatientIdentifierTypeByName_shouldReturnNullWhenPatientIdentifierTypeWithGivenNameDoesNotExist.
/**
* @see PatientService#getPatientIdentifierTypeByName(String)
*/
@Test
public void getPatientIdentifierTypeByName_shouldReturnNullWhenPatientIdentifierTypeWithGivenNameDoesNotExist() throws Exception {
PatientIdentifierType identifierType = Context.getPatientService().getPatientIdentifierTypeByName("Invalid Identifier Example");
Assert.assertNull(identifierType);
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method getPatientIdentifierType_shouldReturnNullWhenPatientIdentifierIdentifierDoesNotExist.
/**
* @see PatientService#getPatientIdentifierType(Integer)
*/
@Test
public void getPatientIdentifierType_shouldReturnNullWhenPatientIdentifierIdentifierDoesNotExist() throws Exception {
PatientIdentifierType identifierType = Context.getPatientService().getPatientIdentifierType(10000);
Assert.assertNull(identifierType);
}
Aggregations