use of org.openmrs.PersonName in project openmrs-core by openmrs.
the class ProviderServiceTest method newPerson.
private Person newPerson(String name) {
Person person = new Person();
Set<PersonName> personNames = new TreeSet<>();
PersonName personName = new PersonName();
personName.setFamilyName(name);
personNames.add(personName);
person.setNames(personNames);
return person;
}
use of org.openmrs.PersonName 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.PersonName in project openmrs-module-mirebalais by PIH.
the class WristbandTemplateTest method testEstimatedBirthDate.
@Test
public void testEstimatedBirthDate() {
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());
patient.setBirthdateEstimated(true);
PatientIdentifier primaryIdentifier = new PatientIdentifier();
primaryIdentifier.setIdentifier("ZL1234");
primaryIdentifier.setIdentifierType(primaryIdentifierType);
primaryIdentifier.setVoided(false);
patient.addIdentifier(primaryIdentifier);
PatientIdentifier paperRecordIdentifier = new PatientIdentifier();
paperRecordIdentifier.setIdentifier("A00005");
paperRecordIdentifier.setIdentifierType(paperRecordIdentifierType);
paperRecordIdentifier.setVoided(false);
patient.addIdentifier(paperRecordIdentifier);
PersonName name = new PersonName();
name.setGivenName("Ringo");
name.setFamilyName("Starr");
patient.addName(name);
String output = wristbandTemplate.generateWristband(patient, new Location());
assertThat(output, containsString("^FO160,200^FB2150,1,0,L,0^AU^FD1940^FS"));
}
use of org.openmrs.PersonName in project openmrs-module-mirebalais by PIH.
the class MirthIT method testMirthChannelIntegration.
@Test
@DirtiesContext
public void testMirthChannelIntegration() throws Exception {
authenticate();
// if the test patient already exists, delete it and any existing orders
if (patientService.getPatients("2ADMMN").size() > 0) {
Patient patient = patientService.getPatients("2ADMMN").get(0);
for (Order order : orderService.getAllOrdersByPatient(patient)) {
orderService.purgeOrder(order);
}
for (Encounter encounter : encounterService.getEncountersByPatient(patient)) {
encounterService.purgeEncounter(encounter);
}
for (Visit visit : visitService.getVisitsByPatient(patient)) {
visitService.purgeVisit(visit);
}
patientService.purgePatient(patient);
}
// TODO: eventually we should make sure all the necessary fields are included here
// first create and save a patient
Patient patient = new Patient();
patient.setGender("M");
Calendar birthdate = Calendar.getInstance();
birthdate.set(2000, 2, 23);
patient.setBirthdate(birthdate.getTime());
PersonName name = new PersonName();
name.setFamilyName("Test Patient");
name.setGivenName("Mirth Integration");
patient.addName(name);
PatientIdentifier identifier = new PatientIdentifier();
identifier.setIdentifierType(emrApiProperties.getPrimaryIdentifierType());
identifier.setIdentifier("2ADMMN");
identifier.setPreferred(true);
identifier.setLocation(locationService.getLocation("Unknown Location"));
patient.addIdentifier(identifier);
// save the patient
patientService.savePatient(patient);
/**
* Commenting this out because we are not currently sending ADT information to APCS
* String result = listenForResults();
*
* System.out.println(result);
*
* // make sure the appropriate message has been delivered
* TestUtils.assertContains("MSH|^~\\&|||||||ADT^A01||P|2.3", result);
* TestUtils.assertContains("PID|||2ADMMN||Test Patient^Mirth Integration||200003230000|M", result);
*
* // now resave the patient and verify that a patient updated message is sent
* // save the patient to trigger an update event
* patientService.savePatient(patient);
*
* result = listenForResults();
*
* System.out.println(result);
*
* TestUtils.assertContains("MSH|^~\\&|||||||ADT^A08||P|2.3", result);
* TestUtils.assertContains("PID|||2ADMMN||Test Patient^Mirth Integration||200003230000|M", result);
*/
// TODO: eventually we should make sure all the necessary fields are concluded here
// TODO: specifically: sending facility, device location, universal service id, universal service id text, and modality
// ensure that there is a visit for the patient (so that the encounter visit handlers doesn't bomb)
adtService.ensureActiveVisit(patient, locationService.getLocation("Mirebalais Hospital"));
// now create and save the order for this patient
RadiologyOrder order = new RadiologyOrder();
order.setOrderType(orderService.getOrderTypeByUuid(administrationService.getGlobalProperty(RadiologyConstants.GP_RADIOLOGY_TEST_ORDER_TYPE)));
order.setPatient(patient);
// chest x-ray, one view
order.setConcept(conceptService.getConceptByUuid("fc6de1c0-1a36-11e2-a310-aa00f871a3e1"));
order.setAccessionNumber("ACCESSION NUMBER");
order.setDateActivated(new SimpleDateFormat("MM-dd-yyyy").parse("09-09-2012"));
order.setUrgency(Order.Urgency.STAT);
order.setClinicalHistory("Patient fell off horse");
order.setExamLocation(locationService.getLocation("Mirebalais Hospital"));
Encounter encounter = new Encounter();
encounter.setPatient(patient);
encounter.setEncounterDatetime(new Date());
encounter.setLocation(locationService.getLocation("Mirebalais Hospital"));
encounter.setEncounterType(encounterService.getEncounterType(1));
encounter.addOrder(order);
encounter.addProvider(emrApiProperties.getOrderingProviderEncounterRole(), Context.getProviderService().getProvider(1));
encounterService.saveEncounter(encounter);
// TODO: I've changed the configuration so that this sends the message directly to the PACS test server
// TODO: since we aren't getting messages send back from PACS yet, there is no good way to test this
/*String result = listenForResults();
TestUtils.assertContains("MSH|^~\\&||Mirebalais|||||ORM^O01||P|2.3", result);
TestUtils.assertContains("PID|||2ADMMN||Test Patient^Mirth Integration||200003230000|M", result);
TestUtils.assertContains("PV1|||Mirebalais Hospital|||||^User^Super", result);
TestUtils.assertContains("ORC|NW", result);
TestUtils
.assertContains(
"OBR|||ACCESSION NUMBER|36554-4^X-ray of chest, 1 view|||||||||||||||CR||||||||^^^^^STAT||||^Patient fell off horse|||||201209090000",
result);*/
}
use of org.openmrs.PersonName in project openmrs-module-coreapps by openmrs.
the class FindPatientFragmentController method simplify.
SimpleObject simplify(UiUtils ui, EmrApiProperties emrApiProperties, Patient patient) {
PersonName name = patient.getPersonName();
SimpleObject preferredName = SimpleObject.fromObject(name, ui, "givenName", "middleName", "familyName", "familyName2");
preferredName.put("name", ui.format(name));
PatientIdentifierType primaryIdentifierType = emrApiProperties.getPrimaryIdentifierType();
List<PatientIdentifier> primaryIdentifiers = patient.getPatientIdentifiers(primaryIdentifierType);
SimpleObject o = SimpleObject.fromObject(patient, ui, "patientId", "gender", "age", "birthdate", "birthdateEstimated");
o.put("preferredName", preferredName);
o.put("primaryIdentifiers", SimpleObject.fromCollection(primaryIdentifiers, ui, "identifier"));
return o;
}
Aggregations