use of org.openmrs.Location in project openmrs-module-mirebalais by PIH.
the class WristbandComponentTest method testWristbandTemplate.
@Test
public void testWristbandTemplate() {
Date today = new Date();
Location location = testDataManager.location().name("Hôpital Universitaire de Mirebalais").tag(emrApiProperties.getSupportsVisitsLocationTag()).save();
Patient patient = testDataManager.patient().identifier(emrApiProperties.getPrimaryIdentifierType(), "X2ECEX", location).identifier(paperRecordProperties.getPaperRecordIdentifierType(), "A000005", location).birthdate(new DateTime(1940, 7, 7, 5, 5, 5).toDate()).gender("M").name("Ringo", "Starr").save();
String output = wristbandTemplate.generateWristband(patient, location);
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"));
// no message source service, se we are just going to get back the message code for age years and gender
assertThat(output, containsString("^FO160,200^FB1850,1,0,L,0^AT^FDcoreapps.ageYears^FS"));
assertThat(output, containsString("^FO160,200^FB1650,1,0,L,0^AU^FDcoreapps.gender.M A 000005^FS"));
assertThat(output, containsString("^FO100,2400^AT^BY4^BC,150,N^FDX2ECEX^XZ"));
}
use of org.openmrs.Location in project openmrs-module-mirebalais by PIH.
the class PaperRecordServiceIT method shouldCreateTwoDifferentDossierNumbers.
@Test
@DirtiesContext
public void shouldCreateTwoDifferentDossierNumbers() throws Exception {
authenticate();
PatientIdentifierType patientIdentifierType = Context.getPatientService().getPatientIdentifierTypeByUuid("e66645eb-03a8-4991-b4ce-e87318e37566");
when(paperRecordProperties.getPaperRecordIdentifierType()).thenReturn(patientIdentifierType);
Location location = new Location(15);
LocationTag locationTag = new LocationTag(15);
locationTag.setName("tag");
location.addTag(locationTag);
when(paperRecordProperties.getMedicalRecordLocationLocationTag()).thenReturn(locationTag);
PaperRecord paperRecord1 = ((PaperRecordServiceImpl) paperRecordService).createPaperRecord(new Patient(), location);
assertTrue(paperRecord1.getPatientIdentifier().getIdentifier().matches("A\\d{6}"));
PaperRecord paperRecord2 = ((PaperRecordServiceImpl) paperRecordService).createPaperRecord(new Patient(), location);
assertTrue(paperRecord2.getPatientIdentifier().getIdentifier().matches("A\\d{6}"));
assertThat(paperRecord1.getPatientIdentifier().getIdentifier(), not(paperRecord2.getPatientIdentifier().getIdentifier()));
}
use of org.openmrs.Location in project openmrs-module-mirebalais by PIH.
the class MarkAppointmentAsMissedOrCompletedTaskTest method shouldMarkActiveAppointmentsAsCompleteIfConsultAsPartOfVisit.
@Test
public void shouldMarkActiveAppointmentsAsCompleteIfConsultAsPartOfVisit() {
new MarkAppointmentsAsMissedOrCompletedTask().execute();
// sanity check: status isn't changed by default, since there are no consultations associated with this visit
assertThat(appointmentService.getAppointment(4).getStatus(), is(AppointmentStatus.INCONSULTATION));
assertThat(appointmentService.getAppointment(7).getStatus(), is(AppointmentStatus.WALKIN));
assertThat(appointmentService.getAppointment(8).getStatus(), is(AppointmentStatus.WAITING));
Location location1 = locationService.getLocation(1);
// location of the appointments, as defined in test dataset
Location location3 = locationService.getLocation(3);
// now add a visit to one appointment, and a visit with a consult to the other
Appointment appt4 = appointmentService.getAppointment(4);
Visit visit4 = testDataManager.visit().patient(appt4.getPatient()).visitType(1).started(new DateTime(2005, 1, 1, 0, 0, 0).toDate()).save();
appt4.setVisit(visit4);
appointmentService.saveAppointment(appt4);
Appointment appt7 = appointmentService.getAppointment(7);
Visit visit7 = testDataManager.visit().patient(appt7.getPatient()).visitType(1).started(new DateTime(2005, 1, 1, 0, 0, 0).toDate()).encounter(testDataManager.encounter().patient(appt7.getPatient()).encounterDatetime(new DateTime(2005, 1, 1, 0, 0, 0).toDate()).encounterType(emrApiProperties.getVisitNoteEncounterType()).location(location1).save()).save();
appt7.setVisit(visit7);
appointmentService.saveAppointment(appt7);
Appointment appt8 = appointmentService.getAppointment(8);
Visit visit8 = testDataManager.visit().patient(appt8.getPatient()).visitType(1).started(new DateTime(2005, 1, 1, 0, 0, 0).toDate()).encounter(testDataManager.encounter().patient(appt8.getPatient()).encounterDatetime(new DateTime(2005, 1, 1, 0, 0, 0).toDate()).encounterType(emrApiProperties.getVisitNoteEncounterType()).location(location3).save()).save();
appt8.setVisit(visit8);
appointmentService.saveAppointment(appt8);
// run the task again
new MarkAppointmentsAsMissedOrCompletedTask().execute();
// should not be changed because associated visit did not have consult
assertThat(appointmentService.getAppointment(4).getStatus(), is(AppointmentStatus.INCONSULTATION));
// should not be changed since associated visit did not have consult at location
assertThat(appointmentService.getAppointment(7).getStatus(), is(AppointmentStatus.WALKIN));
// should be changed to COMPLETED since associated visit had consult at location
assertThat(appointmentService.getAppointment(8).getStatus(), is(AppointmentStatus.COMPLETED));
}
use of org.openmrs.Location 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.Location in project openmrs-module-pihcore by PIH.
the class DailyCheckInsDataSetManager method checkInWithOtherOrMissingReasons.
private Mapped<CohortDefinition> checkInWithOtherOrMissingReasons(String... excludeValues) {
EncounterWithCodedObsCohortDefinition cd = new EncounterWithCodedObsCohortDefinition();
cd.setName("mirebalaisreports.otherOrUnspecified");
cd.setDescription("{{ message \"mirebalaisreports.otherOrUnspecified\" }}");
cd.addParameter(new Parameter("onOrAfter", "On or after", Date.class));
cd.addParameter(new Parameter("onOrBefore", "On or before", Date.class));
cd.addParameter(new Parameter("locationList", "Locations", Location.class));
cd.addEncounterType(encounterService.getEncounterTypeByUuid(PihEmrConfigConstants.ENCOUNTERTYPE_CHECK_IN_UUID));
cd.setConcept(conceptService.getConceptByMapping("Type of HUM visit", "PIH"));
cd.setIncludeNoObsValue(true);
for (String excludeValue : excludeValues) {
cd.addExcludeCodedValue(conceptService.getConceptByMapping(excludeValue, "PIH"));
}
return Mapped.map(cd, "onOrAfter=${day},onOrBefore=${day+1d-1ms},locationList=${location}");
}
Aggregations