use of org.openmrs.Location in project openmrs-module-pihcore by PIH.
the class PihEncounterQueryLibrary method getEncountersDuringPeriodAtLocation.
@DocumentedDefinition(value = "encountersDuringPeriodAtLocation")
public EncounterQuery getEncountersDuringPeriodAtLocation(List<EncounterType> encounterTypes) {
BasicEncounterQuery q = new BasicEncounterQuery();
q.setWhich(TimeQualifier.ANY);
q.setEncounterTypes(encounterTypes);
q.addParameter(parameter(Date.class, "onOrAfter"));
q.addParameter(parameter(Date.class, "onOrBefore"));
q.addParameter(parameter(Location.class, "locationList"));
return new MappedParametersEncounterQuery(q, ObjectUtil.toMap("onOrAfter=startDate,onOrBefore=endDate,locationList=location"));
}
use of org.openmrs.Location in project openmrs-module-pihcore by PIH.
the class WristbandComponentTest method testWristbandTemplate.
@Test
public void testWristbandTemplate() {
Date today = new Date();
Location location = testDataManager.location().name("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^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"));
// 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-pihcore by PIH.
the class InpatientTransferCohortDefinitionEvaluatorTest method testEvaluateTransferIn.
@Test
public void testEvaluateTransferIn() throws Exception {
Location surgicalWard = locationService.getLocation("Sal Aprè Operasyon");
Date startDate = DateUtil.parseDate("2013-10-03 00:00:00", "yyyy-MM-dd HH:mm:ss");
Date endDate = DateUtil.parseDate("2013-10-03 23:59:59", "yyyy-MM-dd HH:mm:ss");
InpatientTransferCohortDefinition definition = new InpatientTransferCohortDefinition();
definition.setOnOrAfter(startDate);
definition.setOnOrBefore(endDate);
definition.setInToWard(surgicalWard);
EvaluatedCohort result = cohortDefinitionService.evaluate(definition, new EvaluationContext());
assertThat(result, isCohortWithExactlyIds(patient5.getId()));
}
use of org.openmrs.Location in project openmrs-module-pihcore by PIH.
the class DailyCheckInsDataSetManagerTest method setup.
@Before
@Override
public void setup() throws Exception {
super.setup();
VisitType atFacility = emrApiProperties.getAtFacilityVisitType();
Location registrationDesk = locationService.getLocation("Biwo Resepsyon");
Location outpatient = locationService.getLocation("Klinik Ekstèn");
Location mirebalaisHospital = locationService.getLocation("Hôpital Universitaire de Mirebalais - Prensipal");
EncounterType registration = getRegistrationEncounterType();
EncounterType checkIn = getCheckInEncounterType();
EncounterType consult = getConsultationEncounterType();
// never registered or seen
data.randomPatient().age(50).dateCreated("2013-10-01").save();
// registered at Clinic Registration, checked in at Outpatient Clinic for a CLINICAL visit (and had a consult)
p2 = data.randomPatient().age(50).save();
Visit v1 = data.visit().patient(p2).visitType(atFacility).started("2013-10-01 09:30:00").stopped("2013-10-01 16:45:00").location(mirebalaisHospital).save();
data.encounter().visit(v1).encounterType(registration).location(registrationDesk).encounterDatetime("2013-10-01 09:30:00").save();
Encounter p2CheckIn = data.encounter().visit(v1).encounterType(checkIn).location(outpatient).encounterDatetime("2013-10-01 09:45:00").save();
data.obs().encounter(p2CheckIn).concept("Type of HUM visit", "PIH").value("CLINICAL", "PIH").save();
data.encounter().visit(v1).encounterType(consult).encounterDatetime("2013-10-01 10:45:00").location(outpatient).save();
// checked in at Outpatient Clinic for a Pharmacy only visit
p3 = data.randomPatient().age(50).save();
data.encounter().patient(p3).encounterType(registration).location(registrationDesk).encounterDatetime("2013-01-01 09:30:00").save();
Visit v2 = data.visit().patient(p3).visitType(atFacility).started("2013-10-01 10:30:00").stopped("2013-10-01 16:45:00").location(mirebalaisHospital).save();
Encounter p3checkIn = data.encounter().visit(v2).encounterType(checkIn).location(outpatient).encounterDatetime("2013-10-01 10:45:00").save();
data.obs().encounter(p3checkIn).concept("Type of HUM visit", "PIH").value("Pharmacy only", "PIH").save();
// registered before and had a consult, then checked in again today for a CLINICAL visit (but no consult yet)
p4 = data.randomPatient().age(50).save();
data.encounter().patient(p4).encounterType(consult).encounterDatetime("2009-01-01").location(outpatient).save();
Visit v3 = data.visit().patient(p4).visitType(atFacility).started("2013-10-01 14:30:00").location(mirebalaisHospital).save();
Encounter p4CheckIn = data.encounter().visit(v3).encounterType(checkIn).location(outpatient).encounterDatetime("2013-10-01 14:30:00").save();
data.obs().encounter(p4CheckIn).concept("Type of HUM visit", "PIH").value("CLINICAL", "PIH").save();
}
use of org.openmrs.Location in project openmrs-module-pihcore by PIH.
the class InpatientLocationCohortDefinitionEvaluatorTest method testThatTransferOutsAreNotIncluded.
@Test
public void testThatTransferOutsAreNotIncluded() throws Exception {
InpatientLocationCohortDefinition definition = new InpatientLocationCohortDefinition();
definition.addParameter(new Parameter("ward", "Ward", Location.class));
definition.addParameter(new Parameter("effectiveDate", "Date", Date.class));
Location womensInternalMedicine = locationService.getLocation("Sal Fanm");
EvaluationContext ec = new EvaluationContext();
ec.addParameterValue("ward", womensInternalMedicine);
Date endOfDay = DateUtil.parseDate("2013-10-03 23:59:59", "yyyy-MM-dd HH:mm:ss");
ec.addParameterValue("effectiveDate", endOfDay);
EvaluatedCohort result = cohortDefinitionService.evaluate(definition, ec);
assertThat(result, isCohortWithExactlyIds(patient1.getId()));
}
Aggregations