@Test public void getMothers_shouldReturnAllMothersOfPatient() { Patient parent = TestUtils.getPatient(7); Patient child = TestUtils.getPatient(2); TestUtils.saveRelationship(parent, Context.getPersonService().getRelationshipType(2), child); SimpleObject[] mothers = controller.getMothers(child, ui); Assert.assertThat(mothers, arrayWithSize(1)); Assert.assertThat(mothers[0], hasEntry("id", (Object) (7))); }
public SimpleObject[] getMothers(@RequestParam("patientId") Patient patient,UiUtils ui) { List<Person> people = new ArrayList<Person>(); for (Relationship relationship : Context.getPersonService().getRelationshipsByPerson(patient)) { if (relationship.getRelationshipType().getbIsToA().equals("Parent")) { if (relationship.getPersonB().getGender().equals("F")) { people.add(relationship.getPersonB()); } } if (relationship.getRelationshipType().getaIsToB().equals("Parent")) { if (relationship.getPersonA().getGender().equals("F")) { people.add(relationship.getPersonA()); } } } return ui.simplifyCollection(people); }
PatientUtilsFragmentController { public SimpleObject[] getMothers(@RequestParam("patientId") Patient patient,UiUtils ui) { List<Person> people = new ArrayList<Person>(); for (Relationship relationship : Context.getPersonService().getRelationshipsByPerson(patient)) { if (relationship.getRelationshipType().getbIsToA().equals("Parent")) { if (relationship.getPersonB().getGender().equals("F")) { people.add(relationship.getPersonB()); } } if (relationship.getRelationshipType().getaIsToB().equals("Parent")) { if (relationship.getPersonA().getGender().equals("F")) { people.add(relationship.getPersonA()); } } } return ui.simplifyCollection(people); } }
PatientUtilsFragmentController { public SimpleObject[] getMothers(@RequestParam("patientId") Patient patient,UiUtils ui) { List<Person> people = new ArrayList<Person>(); for (Relationship relationship : Context.getPersonService().getRelationshipsByPerson(patient)) { if (relationship.getRelationshipType().getbIsToA().equals("Parent")) { if (relationship.getPersonB().getGender().equals("F")) { people.add(relationship.getPersonB()); } } if (relationship.getRelationshipType().getaIsToB().equals("Parent")) { if (relationship.getPersonA().getGender().equals("F")) { people.add(relationship.getPersonA()); } } } return ui.simplifyCollection(people); }  }
PatientUtilsFragmentController { public SimpleObject[] getMothers(@RequestParam("patientId") Patient patient,UiUtils ui) { List<Person> people = new ArrayList<Person>(); for (Relationship relationship : Context.getPersonService().getRelationshipsByPerson(patient)) { if (relationship.getRelationshipType().getbIsToA().equals("Parent")) { if (relationship.getPersonB().getGender().equals("F")) { people.add(relationship.getPersonB()); } } if (relationship.getRelationshipType().getaIsToB().equals("Parent")) { if (relationship.getPersonA().getGender().equals("F")) { people.add(relationship.getPersonA()); } } } return ui.simplifyCollection(people); }  @SharedAction List<SimpleObject> getFlags(@RequestParam("patientId") Integer patientId, @SpringBean CalculationManager calculationManager); @SharedAction List<SimpleObject> getScheduled(@RequestParam("date") Date date, UiUtils ui); @SharedAction List<SimpleObject> getSeenPatients(@RequestParam("date") Date date, UiUtils ui); @AppAction(EmrConstants.APP_CHART) SimpleObject[] recentlyViewed(UiUtils ui, Session session); SimpleObject age(@RequestParam("patientId") Patient patient, @RequestParam("now") Date now); SimpleObject[] getMothers(@RequestParam("patientId") Patient patient,UiUtils ui); SimpleObject[] getFathers(@RequestParam("patientId") Patient patient,UiUtils ui); String patientExist(@RequestParam("patientId") String patientId,UiUtils ui); }
PatientUtilsFragmentController { public SimpleObject[] getMothers(@RequestParam("patientId") Patient patient,UiUtils ui) { List<Person> people = new ArrayList<Person>(); for (Relationship relationship : Context.getPersonService().getRelationshipsByPerson(patient)) { if (relationship.getRelationshipType().getbIsToA().equals("Parent")) { if (relationship.getPersonB().getGender().equals("F")) { people.add(relationship.getPersonB()); } } if (relationship.getRelationshipType().getaIsToB().equals("Parent")) { if (relationship.getPersonA().getGender().equals("F")) { people.add(relationship.getPersonA()); } } } return ui.simplifyCollection(people); }  @SharedAction List<SimpleObject> getFlags(@RequestParam("patientId") Integer patientId, @SpringBean CalculationManager calculationManager); @SharedAction List<SimpleObject> getScheduled(@RequestParam("date") Date date, UiUtils ui); @SharedAction List<SimpleObject> getSeenPatients(@RequestParam("date") Date date, UiUtils ui); @AppAction(EmrConstants.APP_CHART) SimpleObject[] recentlyViewed(UiUtils ui, Session session); SimpleObject age(@RequestParam("patientId") Patient patient, @RequestParam("now") Date now); SimpleObject[] getMothers(@RequestParam("patientId") Patient patient,UiUtils ui); SimpleObject[] getFathers(@RequestParam("patientId") Patient patient,UiUtils ui); String patientExist(@RequestParam("patientId") String patientId,UiUtils ui);  }