@Test public void shouldPutEncounterWithNullDateAtTheTopWhenItsAtTheTop() { final Observation observation1 = createObservation(createEncounter("c1", null), "01"); final Observation observation2 = createObservation(createEncounter("c2", new Date(1)), "02"); final Encounters encounters = new Encounters(observation1, observation2); encounters.sortByDate(); final Encounters expectedOrderedConcept = new Encounters() {{ add(encounterWithObservations(observation1)); add(encounterWithObservations(observation2)); }}; assertThat(encounters, is(expectedOrderedConcept)); }
public void sortByDate() { Collections.sort(this, new Comparator<EncounterWithObservations>() { @Override public int compare(EncounterWithObservations lhs, EncounterWithObservations rhs) { if (lhs.getEncounter().getEncounterDatetime()==null) return -1; if (rhs.getEncounter().getEncounterDatetime()==null) return 1; return -(lhs.getEncounter().getEncounterDatetime() .compareTo(rhs.getEncounter().getEncounterDatetime())); } }); }
Encounters extends ArrayList<EncounterWithObservations> { public void sortByDate() { Collections.sort(this, new Comparator<EncounterWithObservations>() { @Override public int compare(EncounterWithObservations lhs, EncounterWithObservations rhs) { if (lhs.getEncounter().getEncounterDatetime()==null) return -1; if (rhs.getEncounter().getEncounterDatetime()==null) return 1; return -(lhs.getEncounter().getEncounterDatetime() .compareTo(rhs.getEncounter().getEncounterDatetime())); } }); } }
Encounters extends ArrayList<EncounterWithObservations> { public void sortByDate() { Collections.sort(this, new Comparator<EncounterWithObservations>() { @Override public int compare(EncounterWithObservations lhs, EncounterWithObservations rhs) { if (lhs.getEncounter().getEncounterDatetime()==null) return -1; if (rhs.getEncounter().getEncounterDatetime()==null) return 1; return -(lhs.getEncounter().getEncounterDatetime() .compareTo(rhs.getEncounter().getEncounterDatetime())); } }); } Encounters();  Encounters(Observation... observations);  Encounters(List<Observation> observationsByPatient); }
Encounters extends ArrayList<EncounterWithObservations> { public void sortByDate() { Collections.sort(this, new Comparator<EncounterWithObservations>() { @Override public int compare(EncounterWithObservations lhs, EncounterWithObservations rhs) { if (lhs.getEncounter().getEncounterDatetime()==null) return -1; if (rhs.getEncounter().getEncounterDatetime()==null) return 1; return -(lhs.getEncounter().getEncounterDatetime() .compareTo(rhs.getEncounter().getEncounterDatetime())); } }); } Encounters();  Encounters(Observation... observations);  Encounters(List<Observation> observationsByPatient); void sortByDate(); }
Encounters extends ArrayList<EncounterWithObservations> { public void sortByDate() { Collections.sort(this, new Comparator<EncounterWithObservations>() { @Override public int compare(EncounterWithObservations lhs, EncounterWithObservations rhs) { if (lhs.getEncounter().getEncounterDatetime()==null) return -1; if (rhs.getEncounter().getEncounterDatetime()==null) return 1; return -(lhs.getEncounter().getEncounterDatetime() .compareTo(rhs.getEncounter().getEncounterDatetime())); } }); } Encounters();  Encounters(Observation... observations);  Encounters(List<Observation> observationsByPatient); void sortByDate();  }