use of org.openmrs.PersonAddress in project openmrs-core by openmrs.
the class PatientServiceTest method createBasicPatient.
/**
* Convenience method to have a Patient object with all required values filled in
*
* @return a mock Patient object that can be saved
*/
private Patient createBasicPatient() {
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.setBirthdate(new Date());
patient.setBirthdateEstimated(true);
patient.setDeathDate(new Date());
patient.setCauseOfDeath(new Concept());
patient.setGender("male");
patient.setDeathdateEstimated(true);
return patient;
}
use of org.openmrs.PersonAddress in project openmrs-core by openmrs.
the class PatientServiceTest method mergePatients_shouldMaintainSimilarButDifferentAddresses.
@Test
public void mergePatients_shouldMaintainSimilarButDifferentAddresses() throws Exception {
executeDataSet(PATIENT_MERGE_XML);
Patient preferredPatient = patientService.getPatient(10000);
Patient nonPreferredPatient = patientService.getPatient(10001);
patientService.mergePatients(preferredPatient, nonPreferredPatient);
Set<PersonAddress> addresses = preferredPatient.getAddresses();
assertThat(addresses, containsAddress("a1:Apartment ABC, a2:123 fake st, cv:Faketown, sp:null, c:null, cd:null, nc:null, pc:1234, lat:null, long:null"));
assertThat(addresses, containsAddress("a1:Apartment ABC, a2:123 fake st, cv:Faketown, sp:Fakeland, c:null, cd:null, nc:null, pc:null, lat:null, long:null"));
}
use of org.openmrs.PersonAddress in project openmrs-core by openmrs.
the class AuditableInterceptorTest method createPersonWithNameAndAddress.
private Person createPersonWithNameAndAddress() {
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);
return person;
}
use of org.openmrs.PersonAddress in project openmrs-core by openmrs.
the class PersonSaveHandlerTest method handle_shouldIgnoreBlankAddresses.
/**
* @see PersonSaveHandler#handle(Person,User, Date,String)
*/
@Test
public void handle_shouldIgnoreBlankAddresses() {
PersonSaveHandler handler = new PersonSaveHandler();
Person person = new Person();
PersonName personName = new PersonName("John", "", "Smith");
person.addName(personName);
person.setGender("M");
PersonAddress personAddress = new PersonAddress();
personAddress.setAddress1(" ");
person.addAddress(personAddress);
handler.handle(person, null, null, null);
Assert.assertEquals(0, person.getAddresses().size());
}
use of org.openmrs.PersonAddress in project openmrs-core by openmrs.
the class PatientValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.
/**
* @see PatientValidator#validate(Object,Errors)
*/
@Override
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
PatientIdentifierType patientIdentifierType = Context.getPatientService().getAllPatientIdentifierTypes(false).get(0);
Patient patient = new Patient();
PersonName pName = new PersonName();
pName.setGivenName("Tom");
pName.setMiddleName("E.");
pName.setFamilyName("Patient");
patient.addName(pName);
patient.setGender("male");
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);
PatientIdentifier patientIdentifier1 = new PatientIdentifier();
patientIdentifier1.setLocation(new Location(1));
patientIdentifier1.setIdentifier("012345678");
patientIdentifier1.setDateCreated(new Date());
patientIdentifier1.setIdentifierType(patientIdentifierType);
patient.addIdentifier(patientIdentifier1);
patient.setVoidReason("voidReason");
Errors errors = new BindException(patient, "patient");
validator.validate(patient, errors);
Assert.assertFalse(errors.hasErrors());
}
Aggregations