Skip to content

Instantly share code, notes, and snippets.

@djazayeri
Created March 23, 2017 16:11
Show Gist options
  • Save djazayeri/4566e193ff51ec3c39335c022ac86a7a to your computer and use it in GitHub Desktop.
Save djazayeri/4566e193ff51ec3c39335c022ac86a7a to your computer and use it in GitHub Desktop.
public class EvaluatedCohortResourceTest extends BaseEvaluatedResourceTest<EvaluatedCohortResource, EvaluatedCohort> {
// original file content was here
// I added this to the end
@Test
public void andelaExample() throws Exception {
GenderCohortDefinition query1 = new GenderCohortDefinition();
query1.setMaleIncluded(true);
AgeCohortDefinition query2 = new AgeCohortDefinition();
query2.setMinAge(15);
// BEGIN added this after the call; this is how I should have done it in the first place
DefinitionLibraryCohortDefinition alternative1 = new DefinitionLibraryCohortDefinition
("reporting.library.cohortDefinition.builtIn.males");
DefinitionLibraryCohortDefinition alternative2 = new DefinitionLibraryCohortDefinition
("reporting.library.cohortDefinition.builtIn.atLeastAgeOnDate");
alternative2.addParameterValue("minAge", 15);
// END added this after the call; this is how I should have done it in the first place
Map<String, Mapped<CohortDefinition>> searches = new HashMap<String, Mapped<CohortDefinition>>();
searches.put("1", Mapped.<CohortDefinition>noMappings(query1));
searches.put("2", Mapped.<CohortDefinition>noMappings(query2));
CompositionCohortDefinition composition = new CompositionCohortDefinition();
composition.setCompositionString("1 AND 2");
composition.setSearches(searches);
OpenmrsSerializer serializer = Context.getSerializationService().getSerializer(ReportingSerializer.class);
String xml = serializer.serialize(composition);
System.out.println(xml);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment