Search in sources :

Example 91 with Location

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"));
}
Also used : MappedParametersEncounterQuery(org.openmrs.module.reporting.query.encounter.definition.MappedParametersEncounterQuery) Date(java.util.Date) BasicEncounterQuery(org.openmrs.module.reporting.query.encounter.definition.BasicEncounterQuery) Location(org.openmrs.Location) DocumentedDefinition(org.openmrs.module.reporting.definition.library.DocumentedDefinition)

Example 92 with 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"));
}
Also used : Patient(org.openmrs.Patient) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Date(java.util.Date) DateTime(org.joda.time.DateTime) Location(org.openmrs.Location) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 93 with Location

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()));
}
Also used : EvaluatedCohort(org.openmrs.module.reporting.cohort.EvaluatedCohort) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) Date(java.util.Date) InpatientTransferCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.InpatientTransferCohortDefinition) Location(org.openmrs.Location) BaseInpatientReportTest(org.openmrs.module.pihcore.reporting.BaseInpatientReportTest) Test(org.junit.Test)

Example 94 with Location

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();
}
Also used : Visit(org.openmrs.Visit) VisitType(org.openmrs.VisitType) Encounter(org.openmrs.Encounter) EncounterType(org.openmrs.EncounterType) Location(org.openmrs.Location) Before(org.junit.Before)

Example 95 with Location

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()));
}
Also used : InpatientLocationCohortDefinition(org.openmrs.module.pihcore.reporting.cohort.definition.InpatientLocationCohortDefinition) Parameter(org.openmrs.module.reporting.evaluation.parameter.Parameter) EvaluatedCohort(org.openmrs.module.reporting.cohort.EvaluatedCohort) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) Date(java.util.Date) Location(org.openmrs.Location) BaseInpatientReportTest(org.openmrs.module.pihcore.reporting.BaseInpatientReportTest) Test(org.junit.Test)

Aggregations

Location (org.openmrs.Location)235 Test (org.junit.Test)161 Date (java.util.Date)80 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)74 Patient (org.openmrs.Patient)66 Encounter (org.openmrs.Encounter)38 SimpleObject (org.openmrs.ui.framework.SimpleObject)32 PatientIdentifierType (org.openmrs.PatientIdentifierType)31 VisitDomainWrapper (org.openmrs.module.emrapi.visit.VisitDomainWrapper)31 Visit (org.openmrs.Visit)28 AppContextModel (org.openmrs.module.appframework.context.AppContextModel)28 Obs (org.openmrs.Obs)27 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)27 PatientIdentifier (org.openmrs.PatientIdentifier)26 Concept (org.openmrs.Concept)19 EncounterType (org.openmrs.EncounterType)18 DateTime (org.joda.time.DateTime)17 ArrayList (java.util.ArrayList)15 VisitContextModel (org.openmrs.module.coreapps.contextmodel.VisitContextModel)15 BindException (org.springframework.validation.BindException)15