use of org.openmrs.PersonAddress in project openmrs-core by openmrs.
the class PersonServiceTest method createTestPatient.
/*
* Helper to create patient that does not have any existing relationships. Returns created Patient.
*/
private Patient createTestPatient() {
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.setBirthdate(new Date());
patient.setBirthdateEstimated(true);
patient.setDeathDate(new Date());
patient.setCauseOfDeath(new Concept(1));
patient.setGender("male");
List<PatientIdentifierType> patientIdTypes = ps.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 TreeSet<>();
patientIdentifiers.add(patientIdentifier);
patient.setIdentifiers(patientIdentifiers);
ps.savePatient(patient);
return patient;
}
use of org.openmrs.PersonAddress in project openmrs-core by openmrs.
the class PersonServiceTest method unvoidPersonAddress_shouldUnvoidVoidedpersonAddress.
/**
* @see PersonService#unvoidPersonAddress(org.openmrs.PersonAddress)
*/
@Test
public void unvoidPersonAddress_shouldUnvoidVoidedpersonAddress() throws Exception {
executeDataSet("org/openmrs/api/include/PersionServiceTest-voidUnvoidPersonAddress.xml");
PersonAddress voidedPersonAddress = Context.getPersonService().getPersonAddressByUuid("33ghghb5-821c-4e5e-ad1d-a9bce331e777");
assertTrue(voidedPersonAddress.getVoided());
PersonAddress unvoidedPersonAddress = Context.getPersonService().unvoidPersonAddress(voidedPersonAddress);
Assert.assertFalse(unvoidedPersonAddress.getVoided());
Assert.assertNull(unvoidedPersonAddress.getVoidedBy());
Assert.assertNull(unvoidedPersonAddress.getDateVoided());
Assert.assertNull(unvoidedPersonAddress.getVoidReason());
}
use of org.openmrs.PersonAddress in project openmrs-core by openmrs.
the class PersonServiceTest method getPersonAddressByUuid_shouldFindObjectGivenValidUuid.
/**
* @see PersonService#getPersonAddressByUuid(String)
*/
@Test
public void getPersonAddressByUuid_shouldFindObjectGivenValidUuid() throws Exception {
String uuid = "3350d0b5-821c-4e5e-ad1d-a9bce331e118";
PersonAddress personAddress = Context.getPersonService().getPersonAddressByUuid(uuid);
Assert.assertEquals(2, (int) personAddress.getPersonAddressId());
}
use of org.openmrs.PersonAddress in project openmrs-core by openmrs.
the class PersonServiceTest method savePerson_shouldSetThePreferredNameAndAddressIfNoneIsSpecified.
/**
* @see PersonService#savePerson(Person)
*/
@Test
public void savePerson_shouldSetThePreferredNameAndAddressIfNoneIsSpecified() throws Exception {
Person person = new Person();
person.setGender("M");
PersonName name = new PersonName("givenName", "middleName", "familyName");
person.addName(name);
PersonAddress address = new PersonAddress();
address.setAddress1("some address");
person.addAddress(address);
personService.savePerson(person);
assertTrue(name.getPreferred());
assertTrue(address.getPreferred());
}
use of org.openmrs.PersonAddress in project openmrs-core by openmrs.
the class PersonServiceTest method voidPersonAddress_shouldVoidPersonAddressWithTheGivenReason.
/**
* @see PersonService#voidPersonAddress(org.openmrs.PersonAddress, String)
*/
@Test
public void voidPersonAddress_shouldVoidPersonAddressWithTheGivenReason() throws Exception {
executeDataSet("org/openmrs/api/include/PersionServiceTest-voidUnvoidPersonAddress.xml");
PersonAddress personAddress = Context.getPersonService().getPersonAddressByUuid("33ghd0b5-821c-4e5e-ad1d-a9bce331e118");
Assert.assertFalse(personAddress.getVoided());
PersonAddress voidedPersonAddress = Context.getPersonService().voidPersonAddress(personAddress, "Test Voiding PersonAddress");
assertTrue(voidedPersonAddress.getVoided());
Assert.assertNotNull(voidedPersonAddress.getVoidedBy());
Assert.assertNotNull(voidedPersonAddress.getDateVoided());
Assert.assertEquals(voidedPersonAddress.getVoidReason(), "Test Voiding PersonAddress");
}
Aggregations