use of org.openmrs.PersonAddress in project openmrs-module-mirebalais by PIH.
the class WristbandTemplateTest method testWristBandTemplate.
@Test
public void testWristBandTemplate() {
Date today = new Date();
visitLocation.setName("Hôpital Universitaire de Mirebalais");
Patient patient = new Patient();
patient.setGender("M");
patient.setBirthdate(new DateTime(1940, 7, 7, 5, 5, 5).toDate());
PatientIdentifier primaryIdentifier = new PatientIdentifier();
primaryIdentifier.setIdentifier("ZL1234");
primaryIdentifier.setIdentifierType(primaryIdentifierType);
primaryIdentifier.setVoided(false);
patient.addIdentifier(primaryIdentifier);
PatientIdentifier paperRecordIdentifier = new PatientIdentifier();
paperRecordIdentifier.setIdentifier("A000005");
paperRecordIdentifier.setIdentifierType(paperRecordIdentifierType);
paperRecordIdentifier.setVoided(false);
paperRecordIdentifier.setLocation(visitLocation);
patient.addIdentifier(paperRecordIdentifier);
PersonAddress address = new PersonAddress();
address.setAddress2("Avant Eglise Chretienne des perlerlerin de la siant tete de moliere");
address.setAddress1("Saut D'Eau");
address.setAddress3("1ere Riviere Canot");
address.setCityVillage("Saut d'Eau");
address.setStateProvince("Centre");
patient.addAddress(address);
PersonName name = new PersonName();
name.setGivenName("Ringo");
name.setFamilyName("Starr");
patient.addName(name);
when(messageSourceService.getMessage("coreapps.ageYears", Collections.singletonList(patient.getAge()).toArray(), locale)).thenReturn(patient.getAge() + " an(s)");
String output = wristbandTemplate.generateWristband(patient, visitLocation);
assertThat(output, containsString("^XA^CI28^MTD^FWB"));
assertThat(output, containsString("^FO050,200^FB2150,1,0,L,0^AS^FDHôpital Universitaire de Mirebalais " + df.format(today) + "^FS"));
assertThat(output, containsString("^FO100,200^FB2150,1,0,L,0^AU^FDRingo Starr^FS"));
assertThat(output, containsString("^FO160,200^FB2150,1,0,L,0^AU^FD07 juil. 1940^FS"));
assertThat(output, containsString("^FO160,200^FB1850,1,0,L,0^AT^FD" + patient.getAge() + " an(s)^FS"));
assertThat(output, containsString("^FO160,200^FB1650,1,0,L,0^AU^FDMasculin A 000005^FS"));
assertThat(output, containsString("^FO220,200^FB2150,1,0,L,0^AS^FDAvant Eglise Chretienne des perlerlerin de la siant tete de moliere^FS"));
assertThat(output, containsString("^FO270,200^FB2150,1,0,L,0^AS^FDSaut D'Eau, 1ere Riviere Canot, Saut d'Eau, Centre^FS"));
assertThat(output, containsString("^FO100,2400^AT^BY4^BC,150,N^FDZL1234^XZ"));
}
use of org.openmrs.PersonAddress in project openmrs-module-pihcore by PIH.
the class ZlEmrIdCardPrinter method getAddressLines.
/**
* @return the address lines in the format that it should be displayed on the id cards
*/
protected List<String> getAddressLines(Patient patient) {
PersonAddress address = patient.getPersonAddress();
if (address == null) {
return null;
}
List<String> addressLines = new ArrayList<String>();
if (AddressSupport.getInstance().getDefaultLayoutTemplate() != null && AddressSupport.getInstance().getDefaultLayoutTemplate().getLines() != null) {
for (List<Map<String, String>> line : AddressSupport.getInstance().getDefaultLayoutTemplate().getLines()) {
// now iterate through all the tokens in the line and build the string to print
StringBuilder output = new StringBuilder();
for (Map<String, String> token : line) {
// find all the tokens on this line, and then add them to that output line
if (token.get("isToken").equals(AddressSupport.getInstance().getDefaultLayoutTemplate().getLayoutToken())) {
try {
String propertyValue = (String) PropertyUtils.getProperty(address, token.get("codeName"));
if (StringUtils.isNotBlank(propertyValue)) {
if (output.length() > 0) {
output.append(", ");
}
output.append(propertyValue);
}
} catch (Exception e) {
log.error("Invalid address property of " + token.get("codeName") + " configured in address layout template", e);
}
}
}
if (StringUtils.isNotBlank(output.toString())) {
addressLines.add(output.toString());
}
}
} else {
log.error("Address template not properly configured");
}
return addressLines;
}
use of org.openmrs.PersonAddress in project openmrs-module-pihcore by PIH.
the class BaseReportTest method address.
protected PatientBuilder address(PatientBuilder pb, List<AddressComponent> addressComponents, String... values) {
PersonAddress a = new PersonAddress();
int index = 0;
for (AddressComponent property : addressComponents) {
ReflectionUtil.setPropertyValue(a, property.getField().getName(), values[index]);
index++;
}
return pb.address(a);
}
use of org.openmrs.PersonAddress in project openmrs-module-pihcore by PIH.
the class WristbandTemplateTest method testWristBandTemplate.
@Test
public void testWristBandTemplate() {
Date today = new Date();
visitLocation.setName("Mirebalais");
Patient patient = new Patient();
patient.setGender("M");
patient.setBirthdate(new DateTime(1940, 7, 7, 5, 5, 5).toDate());
PatientIdentifier primaryIdentifier = new PatientIdentifier();
primaryIdentifier.setIdentifier("ZL1234");
primaryIdentifier.setIdentifierType(primaryIdentifierType);
primaryIdentifier.setVoided(false);
patient.addIdentifier(primaryIdentifier);
PatientIdentifier paperRecordIdentifier = new PatientIdentifier();
paperRecordIdentifier.setIdentifier("A000005");
paperRecordIdentifier.setIdentifierType(paperRecordIdentifierType);
paperRecordIdentifier.setVoided(false);
paperRecordIdentifier.setLocation(visitLocation);
patient.addIdentifier(paperRecordIdentifier);
PersonAddress address = new PersonAddress();
address.setAddress2("Avant Eglise Chretienne des perlerlerin de la siant tete de moliere");
address.setAddress1("Saut D'Eau");
address.setAddress3("1ere Riviere Canot");
address.setCityVillage("Saut d'Eau");
address.setStateProvince("Centre");
patient.addAddress(address);
PersonName name = new PersonName();
name.setGivenName("Ringo");
name.setFamilyName("Starr");
patient.addName(name);
when(messageSourceService.getMessage("coreapps.ageYears", Collections.singletonList(patient.getAge()).toArray(), locale)).thenReturn(patient.getAge() + " an(s)");
String output = wristbandTemplate.generateWristband(patient, visitLocation);
assertThat(output, containsString("^XA^CI28^MTD^FWB"));
assertThat(output, containsString("^FO050,200^FB2150,1,0,L,0^AS^FDMirebalais " + df.format(today) + "^FS"));
assertThat(output, containsString("^FO100,200^FB2150,1,0,L,0^AU^FDRingo Starr^FS"));
assertThat(output, containsString("^FO160,200^FB2150,1,0,L,0^AU^FD07 juil. 1940^FS"));
assertThat(output, containsString("^FO160,200^FB1850,1,0,L,0^AT^FD" + patient.getAge() + " an(s)^FS"));
assertThat(output, containsString("^FO160,200^FB1650,1,0,L,0^AU^FDMasculin A 000005^FS"));
assertThat(output, containsString("^FO220,200^FB2150,1,0,L,0^AS^FDAvant Eglise Chretienne des perlerlerin de la siant tete de moliere^FS"));
assertThat(output, containsString("^FO270,200^FB2150,1,0,L,0^AS^FDSaut D'Eau, 1ere Riviere Canot, Saut d'Eau, Centre^FS"));
assertThat(output, containsString("^FO100,2400^AT^BY4^BC,150,N^FDZL1234^XZ"));
}
use of org.openmrs.PersonAddress in project openmrs-module-mirebalais by PIH.
the class ZlEmrIdCardPrinter method getAddressLines.
/**
* @return the address lines in the format that it should be displayed on the id cards
*/
protected List<String> getAddressLines(Patient patient) {
PersonAddress address = patient.getPersonAddress();
if (address == null) {
return null;
}
List<String> addressLines = new ArrayList<String>();
if (AddressSupport.getInstance().getDefaultLayoutTemplate() != null && AddressSupport.getInstance().getDefaultLayoutTemplate().getLines() != null) {
for (List<Map<String, String>> line : AddressSupport.getInstance().getDefaultLayoutTemplate().getLines()) {
// now iterate through all the tokens in the line and build the string to print
StringBuilder output = new StringBuilder();
for (Map<String, String> token : line) {
// find all the tokens on this line, and then add them to that output line
if (token.get("isToken").equals(AddressSupport.getInstance().getDefaultLayoutTemplate().getLayoutToken())) {
try {
String propertyValue = (String) PropertyUtils.getProperty(address, token.get("codeName"));
if (StringUtils.isNotBlank(propertyValue)) {
if (output.length() > 0) {
output.append(", ");
}
output.append(propertyValue);
}
} catch (Exception e) {
log.error("Invalid address property of " + token.get("codeName") + " configured in address layout template", e);
}
}
}
if (StringUtils.isNotBlank(output.toString())) {
addressLines.add(output.toString());
}
}
} else {
log.error("Address template not properly configured");
}
return addressLines;
}
Aggregations