示例#1
0
 /**
  * Is this TimePeriod contained by another TimePeriod? Equal start/end times are considered to be
  * containing, as are equal indeterminate times.
  *
  * @param otherTimePeriod Potentially containing TimePeriod
  * @return Whether the argument TimePeriod contains this one
  */
 public boolean isWithin(TimePeriod otherTimePeriod) {
   if (otherTimePeriod == null) {
     throw new NullPointerException("otherTimePeriod cannot be null");
   }
   boolean startWithin = false;
   boolean endWithin = false;
   if (start != null && otherTimePeriod.getStart() != null) {
     startWithin =
         start.isEqual(otherTimePeriod.getStart()) || start.isAfter(otherTimePeriod.getStart());
   } else if (start == null
       && otherTimePeriod.getStart() == null
       && startIndet != null
       && otherTimePeriod.getStartIndet() != null
       && startIndet.equals(otherTimePeriod.getStartIndet())) {
     startWithin = true;
   }
   if (end != null && otherTimePeriod.getEnd() != null) {
     endWithin = end.isEqual(otherTimePeriod.getEnd()) || end.isBefore(otherTimePeriod.getEnd());
   } else if (end == null
       && otherTimePeriod.getEnd() == null
       && endIndet != null
       && otherTimePeriod.getEndIndet() != null
       && endIndet.equals(otherTimePeriod.getEndIndet())) {
     endWithin = true;
   }
   return startWithin && endWithin;
 }
示例#2
0
 @Test
 public void testIndeterminateNowEnd() {
   DateTime beforeResolve = new DateTime();
   DateTime resolvedValue =
       new TimePeriod(new DateTime(), null, null, TimeIndeterminateValue.now).resolveEnd();
   DateTime afterResolve = new DateTime();
   assertNotNull("TimePeriod end now value is null", resolvedValue);
   assertTrue(
       "TimePeriod end now value is too early",
       resolvedValue.isAfter(beforeResolve) || resolvedValue.isEqual(beforeResolve));
   assertTrue(
       "TimePeriod end now value is too late",
       resolvedValue.isBefore(afterResolve) || resolvedValue.isEqual(afterResolve));
 }
  /** 检查营业执照修改情况 */
  private void checkBusinessLicense(
      Map<String, String> changedInfo, PaperworkDto updatedPaperwork, PaperworkDto oldPaperwork) {

    if (!Objects.equal(updatedPaperwork.getBusinessLicense(), oldPaperwork.getBusinessLicense())) {
      changedInfo.put(
          ChangedInfoKeys.companyBusinessLicense(), updatedPaperwork.getBusinessLicense());
    }
    if (!Objects.equal(
        updatedPaperwork.getBusinessLicenseId(), oldPaperwork.getBusinessLicenseId())) {
      changedInfo.put(
          ChangedInfoKeys.companyBusinessLicenseId(), updatedPaperwork.getBusinessLicenseId());
    }

    DateTime updatedBlDate = new DateTime(updatedPaperwork.getBlDate());
    if (oldPaperwork.getBlDate() == null) {
      changedInfo.put(
          ChangedInfoKeys.companyBusinessLicenseDate(), updatedBlDate.toString(FORMATTER));
    } else {
      DateTime oldBlDate = new DateTime(oldPaperwork.getBlDate());
      if (!updatedBlDate.isEqual(oldBlDate)) {
        changedInfo.put(
            ChangedInfoKeys.companyBusinessLicenseDate(), updatedBlDate.toString(FORMATTER));
      }
    }
  }
示例#4
0
 @Test
 public void testIndeterminateNowStart() {
   TimePeriod timePeriod = new TimePeriod(null, TimeIndeterminateValue.now, new DateTime(), null);
   DateTime beforeAccess = new DateTime();
   DateTime nowValue = timePeriod.resolveStart();
   assertNotNull("TimePeriod start now value is null", nowValue);
   assertTrue(
       "TimePeriod start now value is too early",
       nowValue.isAfter(beforeAccess) || nowValue.isEqual(beforeAccess));
   assertTrue(
       "TimePeriod start now value is too late", nowValue.isBeforeNow() || nowValue.isEqualNow());
 }
  private boolean isVersionNewer(String version, String oldVersion) {
    // if we cannot estimate the relation between versions, we accept new records over the old ones.
    boolean retval = true;
    DateTime dt = tryDateFormat(version);
    DateTime dtOld = tryDateFormat(oldVersion);
    if (dt != null && dtOld != null) {
      if (dtOld.isAfter(dt.getMillis()) || dtOld.isEqual(dt.getMillis())) {
        retval = false;
      }
    }

    return retval;
  }
示例#6
0
      @Override
      public int compare(ScheduledJob arg0, ScheduledJob arg1) {
        DateTime first = arg1.getScheduledExecution();
        DateTime second = arg0.getScheduledExecution();

        if (first.isEqual(second)) {
          return 0;
        } else if (first.isBefore(second)) {
          return 1;
        }

        return -1;
      }
  @Test
  public void
      shouldScheduleDailyAdherenceQualityJobsForAPatientOnDailyReminderStartingFromTodayIfTreatmentAdviceStartDateIsInPast() {
    final String patientId = "123456";
    Patient patient =
        PatientBuilder.startRecording()
            .withDefaults()
            .withId(patientId)
            .withCallPreference(CallPreference.DailyPillReminder)
            .build();

    final LocalDate startDate = DateUtil.today().minusDays(2);
    final LocalDate endDate = DateUtil.today().plusDays(2);
    final DateTime timeFewMillisBack = DateUtil.now().minusMillis(1000);

    TreatmentAdvice advice = getTreatmentAdvice(startDate, endDate);

    schedulerService.scheduleJobForDeterminingAdherenceQualityInDailyPillReminder(patient, advice);

    final ArgumentCaptor<CronSchedulableJob> cronArgCaptor =
        ArgumentCaptor.forClass(CronSchedulableJob.class);
    verify(motechSchedulerService).safeScheduleJob(cronArgCaptor.capture());

    CronSchedulableJob jobScheduledWithParams = cronArgCaptor.getValue();
    final MotechEvent motechEventInScheduledJob = jobScheduledWithParams.getMotechEvent();
    Map<String, Object> paramsInScheduledJob = motechEventInScheduledJob.getParameters();

    assertEquals(
        "Should setup the cron expression to run at every midnight.",
        jobScheduledWithParams.getCronExpression(),
        "0 0 0 * * ?");

    DateTime actualTimeWhenTriggerWasActivated =
        DateUtil.newDateTime(jobScheduledWithParams.getStartTime());
    assertTrue(
        "Since the advice has already started in past, we should schedule it starting now, which is after a time few milli seconds back.",
        timeFewMillisBack.isBefore(actualTimeWhenTriggerWasActivated));
    DateTime rightNow = DateUtil.now();
    assertTrue(rightNow.isEqual(actualTimeWhenTriggerWasActivated));

    assertEquals(jobScheduledWithParams.getEndTime(), endDate.plusDays(1).toDate());

    assertEquals(paramsInScheduledJob.get(EventKeys.EXTERNAL_ID_KEY), patientId);
    assertEquals(
        motechEventInScheduledJob.getSubject(), TAMAConstants.DAILY_ADHERENCE_IN_RED_ALERT_SUBJECT);
  }
  /** 检查组织机构修改情况 */
  private void checkOrgCert(
      Map<String, String> changedInfo, PaperworkDto updatedPaperwork, PaperworkDto oldPaperwork) {

    if (!Objects.equal(updatedPaperwork.getOrgCert(), oldPaperwork.getOrgCert())) {
      changedInfo.put(ChangedInfoKeys.companyOrgCert(), updatedPaperwork.getOrgCert());
    }
    if (!Objects.equal(updatedPaperwork.getOrgCertId(), oldPaperwork.getOrgCertId())) {
      changedInfo.put(ChangedInfoKeys.companyOrgCertId(), updatedPaperwork.getOrgCertId());
    }

    DateTime updatedOcDate = new DateTime(updatedPaperwork.getOcDate());
    if (oldPaperwork.getOcDate() == null) {
      changedInfo.put(ChangedInfoKeys.companyOrgCertDate(), updatedOcDate.toString(FORMATTER));
    } else {
      DateTime oldOcDate = new DateTime(oldPaperwork.getOcDate());
      if (!updatedOcDate.isEqual(oldOcDate)) {
        changedInfo.put(ChangedInfoKeys.companyOrgCertDate(), updatedOcDate.toString(FORMATTER));
      }
    }
  }
示例#9
0
 @Override
 public int compare(LaborCostMultiplier o1, LaborCostMultiplier o2) {
   DateTime d1 = o1.getStartDate();
   DateTime d2 = o2.getStartDate();
   return d1.isBefore(d2) ? -1 : (d1.isEqual(d2) ? 0 : 1);
 }
示例#10
0
 @Override
 public int compare(CompensationDetail o1, CompensationDetail o2) {
   DateTime d1 = o1.getStartDate();
   DateTime d2 = o2.getStartDate();
   return d1.isBefore(d2) ? -1 : (d1.isEqual(d2) ? 0 : 1);
 }
 public boolean matchesSafely(DateTime provided) {
   return provided.isEqual(expectedDate);
 }
示例#12
0
 private static boolean isDateOrderingValid(DateTime notValidBefore, DateTime notValidAfter) {
   return (notValidBefore == null
       || notValidAfter == null
       || notValidBefore.isEqual(notValidAfter)
       || notValidBefore.isBefore(notValidAfter));
 }