/** * Returns true if this {@link PatientState} is active as of the passed {@link Date} * * @param onDate - {@link Date} to check for {@link PatientState} enrollment * @return boolean - true if this {@link PatientState} is active as of the passed {@link Date} * @should return false if voided and date in range * @should return false if voided and date not in range * @should return true if not voided and date in range * @should return false if not voided and date earlier than startDate * @should return false if not voided and date later than endDate * @should return true if not voided and date in range with null startDate * @should return true if not voided and date in range with null endDate * @should return true if not voided and both startDate and endDate nulled * @should compare with current date if date null */ public boolean getActive(Date onDate) { if (onDate == null) { onDate = new Date(); } return !getVoided() && (OpenmrsUtil.compareWithNullAsEarliest(startDate, onDate) <= 0) && (OpenmrsUtil.compareWithNullAsLatest(endDate, onDate) > 0); }
ret = -OpenmrsUtil.compareWithNullAsEarliest(this.getStartDate(), o.getStartDate());
/** * Compares by startDate with null as earliest and endDate with null as latest. * * @see java.lang.Comparable#compareTo(java.lang.Object) * @should return positive if startDates equal and this endDate null * @should return negative if this startDate null * @should pass if two states have the same start date, end date and uuid * @should return positive or negative if two states have the same start date and end date but different uuids * Note: this comparator imposes orderings that are inconsistent with equals. */ @SuppressWarnings("squid:S1210") @Override public int compareTo(PatientState o) { int result = OpenmrsUtil.compareWithNullAsEarliest(getStartDate(), o.getStartDate()); if (result == 0) { result = OpenmrsUtil.compareWithNullAsLatest(getEndDate(), o.getEndDate()); } if (result == 0) { result = OpenmrsUtil.compareWithNullAsGreatest(getUuid(), o.getUuid()); } return result; } }
if (OpenmrsUtil.compareWithNullAsEarliest(personAddress.getStartDate(), new Date()) > 0) { errors.rejectValue("startDate", "PersonAddress.error.startDateInFuture", new Object[] { "'" + addressString + "'" }, "The Start Date for address '" + addressString + "' shouldn't be in the future");
errors.rejectValue("states", "PatientProgram.error.cannotBeInMultipleStates"); return; } else if (OpenmrsUtil.compareWithNullAsEarliest(patientState.getStartDate(), latestState .getEndDate()) < 0) { errors.rejectValue("states", "PatientProgram.error.cannotBeInMultipleStates"); return; } else if (OpenmrsUtil.compareWithNullAsEarliest(latestState.getStartDate(), patientState .getEndDate()) < 0) {
@Override public int compare(Encounter left, Encounter right) { return OpenmrsUtil.compareWithNullAsEarliest(left.getEncounterDatetime(), right.getEncounterDatetime()); } });
@Override public int compare(PatientState o1, PatientState o2) { int result = OpenmrsUtil.compareWithNullAsEarliest(o1.getStartDate(), o2.getStartDate()); if (result == 0) { result = OpenmrsUtil.compareWithNullAsLatest(o1.getEndDate(), o2.getEndDate()); } return result; }
session.getSubmissionActions().getObsToVoid().add(existingObsGroup); } else if (checked) { if (existingObsGroup != null && OpenmrsUtil.compareWithNullAsEarliest(existingObsGroup.getObsDatetime(), date) == 0) { return; //nothing changed