Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. public class EvaluatedCohortResourceTest extends BaseEvaluatedResourceTest<EvaluatedCohortResource, EvaluatedCohort> {
  2.  
  3. // original file content was here
  4. // I added this to the end
  5.  
  6. @Test
  7. public void andelaExample() throws Exception {
  8. GenderCohortDefinition query1 = new GenderCohortDefinition();
  9. query1.setMaleIncluded(true);
  10.  
  11. AgeCohortDefinition query2 = new AgeCohortDefinition();
  12. query2.setMinAge(15);
  13.  
  14. // BEGIN added this after the call; this is how I should have done it in the first place
  15. DefinitionLibraryCohortDefinition alternative1 = new DefinitionLibraryCohortDefinition
  16. ("reporting.library.cohortDefinition.builtIn.males");
  17.  
  18. DefinitionLibraryCohortDefinition alternative2 = new DefinitionLibraryCohortDefinition
  19. ("reporting.library.cohortDefinition.builtIn.atLeastAgeOnDate");
  20. alternative2.addParameterValue("minAge", 15);
  21. // END added this after the call; this is how I should have done it in the first place
  22.  
  23. Map<String, Mapped<CohortDefinition>> searches = new HashMap<String, Mapped<CohortDefinition>>();
  24. searches.put("1", Mapped.<CohortDefinition>noMappings(query1));
  25. searches.put("2", Mapped.<CohortDefinition>noMappings(query2));
  26.  
  27. CompositionCohortDefinition composition = new CompositionCohortDefinition();
  28. composition.setCompositionString("1 AND 2");
  29. composition.setSearches(searches);
  30.  
  31. OpenmrsSerializer serializer = Context.getSerializationService().getSerializer(ReportingSerializer.class);
  32. String xml = serializer.serialize(composition);
  33. System.out.println(xml);
  34. }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement