@Test public void shouldReturnFalseWhenPatientIsRegisteredBeforeValidDate() { Calendar cal = Calendar.getInstance(); cal.set(2000, 1, 1); Date birthDate = cal.getTime(); cal.set(2011, 4, 19); Date validRegDate = cal.getTime(); cal.set(2011, 3, 19); Date encounterDate = cal.getTime(); Patient patient = new Patient(); patient.setBirthdate(birthDate); Encounter encounter = new Encounter(); encounter.setEncounterDatetime(encounterDate); when(registerBean.getChildRegistrationDate()).thenReturn(validRegDate); when(registerBean.getEncounters(patient, MotechConstants.ENCOUNTER_TYPE_PATIENTREGVISIT, patient.getBirthdate())).thenReturn(Arrays.asList(encounter)); assertFalse(requirement.meetsRequirement(patient, new Date())); }
public boolean meetsRequirement(Patient patient, Date date) { Date childRegistrationDate = registrarBean.getChildRegistrationDate(); List<Encounter> encounters = registrarBean.getEncounters(patient, MotechConstants.ENCOUNTER_TYPE_PATIENTREGVISIT, patient.getBirthdate()); if (encounters == null || encounters.isEmpty()) return false; return childRegistrationDate.before(encounters.get(0).getEncounterDatetime()); }
RegistrationRequirement implements Requirement { public boolean meetsRequirement(Patient patient, Date date) { Date childRegistrationDate = registrarBean.getChildRegistrationDate(); List<Encounter> encounters = registrarBean.getEncounters(patient, MotechConstants.ENCOUNTER_TYPE_PATIENTREGVISIT, patient.getBirthdate()); if (encounters == null || encounters.isEmpty()) return false; return childRegistrationDate.before(encounters.get(0).getEncounterDatetime()); } }
RegistrationRequirement implements Requirement { public boolean meetsRequirement(Patient patient, Date date) { Date childRegistrationDate = registrarBean.getChildRegistrationDate(); List<Encounter> encounters = registrarBean.getEncounters(patient, MotechConstants.ENCOUNTER_TYPE_PATIENTREGVISIT, patient.getBirthdate()); if (encounters == null || encounters.isEmpty()) return false; return childRegistrationDate.before(encounters.get(0).getEncounterDatetime()); }  }
RegistrationRequirement implements Requirement { public boolean meetsRequirement(Patient patient, Date date) { Date childRegistrationDate = registrarBean.getChildRegistrationDate(); List<Encounter> encounters = registrarBean.getEncounters(patient, MotechConstants.ENCOUNTER_TYPE_PATIENTREGVISIT, patient.getBirthdate()); if (encounters == null || encounters.isEmpty()) return false; return childRegistrationDate.before(encounters.get(0).getEncounterDatetime()); }  boolean meetsRequirement(Patient patient, Date date); RegistrarBean getRegistrarBean(); void setRegistrarBean(RegistrarBean registrarBean); }
RegistrationRequirement implements Requirement { public boolean meetsRequirement(Patient patient, Date date) { Date childRegistrationDate = registrarBean.getChildRegistrationDate(); List<Encounter> encounters = registrarBean.getEncounters(patient, MotechConstants.ENCOUNTER_TYPE_PATIENTREGVISIT, patient.getBirthdate()); if (encounters == null || encounters.isEmpty()) return false; return childRegistrationDate.before(encounters.get(0).getEncounterDatetime()); }  boolean meetsRequirement(Patient patient, Date date); RegistrarBean getRegistrarBean(); void setRegistrarBean(RegistrarBean registrarBean);  }