Using the Reporting Module in other modules

The following code is if you want to use the patient list from one of the cohort queries saved in the reporting module that DO NOT have parameters in them. If they have parameters it gets more complicated.

First, you should use the CohortDefinition class and create an object with an ID that has been previously stored. In this example, the ID is retrived from programming.getCohort()

With that definition, you create the cohort using the cohort service. Finally, you can obtain the list of patients for that query.

The code is here

static private void init(){
                cohortSrv = Context.getService(CohortDefinitionService.class);
        }

CohortDefinition cohort = cohortSrv.getDefinition(CohortDefinition.class, programming.getCohort());
Cohort c = cohortSrv.evaluate(cohort, new EvaluationContext());
List<Patient> patients = Context.getPatientSetService().getPatients(c.getMemberIds())