Search in sources :

Example 11 with Parameter

use of org.openmrs.module.reporting.evaluation.parameter.Parameter in project openmrs-module-pihcore by PIH.

the class ReportingMatchers method hasParameter.

public static Matcher<Definition> hasParameter(final String withName, final Class<?> ofType, final Class<? extends Collection> ofCollectionType) {
    return new BaseMatcher<Definition>() {

        @Override
        public boolean matches(Object o) {
            Definition actual = (Definition) o;
            Parameter parameter = actual.getParameter(withName);
            return parameter != null && parameter.getType().equals(ofType) && ((ofCollectionType == null && parameter.getCollectionType() == null) || (ofCollectionType != null && ofCollectionType.equals(parameter.getCollectionType())));
        }

        // TODO fix this implementation or figure out which other matcher implementation to use
        @Override
        public void describeTo(Description description) {
            description.appendText("should have parameter " + withName + " of type " + ofType + " and collection type " + ofCollectionType);
        }
    };
}
Also used : Description(org.hamcrest.Description) BaseMatcher(org.hamcrest.BaseMatcher) Definition(org.openmrs.module.reporting.evaluation.Definition) Parameter(org.openmrs.module.reporting.evaluation.parameter.Parameter)

Example 12 with Parameter

use of org.openmrs.module.reporting.evaluation.parameter.Parameter in project openmrs-module-pihcore by PIH.

the class BaseEncounterDataSetManager method constructDataSet.

public DataSetDefinition constructDataSet() {
    EncounterDataSetDefinition dsd = new EncounterDataSetDefinition();
    dsd.addParameter(new Parameter("startDate", "mirebalaisreports.parameter.startDate", Date.class));
    dsd.addParameter(new Parameter("endDate", "mirebalaisreports.parameter.endDate", Date.class));
    // Rows defined as patients who had an encounter of the configured types during the given period
    dsd.addRowFilter(Mapped.mapStraightThrough(new PatientEncounterQuery(cohortQueries.getExcludeTestPatients())));
    dsd.addRowFilter(Mapped.mapStraightThrough(encounterQueries.getEncountersDuringPeriodAtLocation(getEncounterTypes())));
    // Define columns
    addPrimaryIdentifierColumns(dsd);
    addPatientNameColumns(dsd);
    addBirthDateAndAgeColumns(dsd);
    addGenderColumns(dsd);
    addOtherIdentifierColumns(dsd);
    addCoreEncounterColumns(dsd);
    addCoreVisitColumns(dsd);
    addAddressColumns(dsd);
    addPersonAttributeColumns(dsd);
    addObsColumns(dsd);
    addAuditColumns(dsd);
    return dsd;
}
Also used : PatientEncounterQuery(org.openmrs.module.reporting.query.encounter.definition.PatientEncounterQuery) Parameter(org.openmrs.module.reporting.evaluation.parameter.Parameter) EncounterDataSetDefinition(org.openmrs.module.reporting.dataset.definition.EncounterDataSetDefinition) Date(java.util.Date)

Aggregations

Parameter (org.openmrs.module.reporting.evaluation.parameter.Parameter)12 Date (java.util.Date)11 Location (org.openmrs.Location)7 MappedParametersCohortDefinition (org.openmrs.module.reporting.cohort.definition.MappedParametersCohortDefinition)6 DocumentedDefinition (org.openmrs.module.reporting.definition.library.DocumentedDefinition)6 Test (org.junit.Test)2 BaseInpatientReportTest (org.openmrs.module.pihcore.reporting.BaseInpatientReportTest)2 DiedSoonAfterEncounterCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.DiedSoonAfterEncounterCohortDefinition)2 InpatientLocationCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.InpatientLocationCohortDefinition)2 InpatientTransferCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.InpatientTransferCohortDefinition)2 EvaluatedCohort (org.openmrs.module.reporting.cohort.EvaluatedCohort)2 EvaluationContext (org.openmrs.module.reporting.evaluation.EvaluationContext)2 List (java.util.List)1 BaseMatcher (org.hamcrest.BaseMatcher)1 Description (org.hamcrest.Description)1 Concept (org.openmrs.Concept)1 DiagnosisCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.DiagnosisCohortDefinition)1 LastDispositionBeforeExitCohortDefinition (org.openmrs.module.pihcore.reporting.cohort.definition.LastDispositionBeforeExitCohortDefinition)1 EncounterCohortDefinition (org.openmrs.module.reporting.cohort.definition.EncounterCohortDefinition)1 EncounterWithCodedObsCohortDefinition (org.openmrs.module.reporting.cohort.definition.EncounterWithCodedObsCohortDefinition)1