/** @throws Exception */
  @Test
  public void addConsumedMedicationWeekly() throws Exception {

    int oldSize = patientMedicationDao.findAll().size();

    Patient patient = (Patient) userService.findUserByLogin("sysuser1");
    assertNotNull(patient);
    Medication medication = medicationService.findByName("Kort 2", Locale.GERMANY).get(0);

    Disease disease = diseaseService.findByCode(DiseaseCodes.RHEUMA_CODE);
    assertNotNull(disease);

    DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
    Date startDate = dateFormat.parse("1.11.2010");
    Date endDate = dateFormat.parse("28.11.2010");

    patientMedicationService.addConsumedMedication(
        patient.getId(),
        disease.getId(),
        medication.getId(),
        2.0d,
        MedicationFrequency.WEEKLY,
        startDate,
        endDate,
        null);
    assertEquals(oldSize + 4, patientMedicationDao.findAll().size());
  }
  /** @throws Exception */
  @Test
  public void addConsumedMedication() throws Exception {

    int oldSize = patientMedicationDao.findAll().size();

    Patient patient = (Patient) userService.findUserByLogin("sysuser1");
    assertNotNull(patient);
    Medication medication = medicationService.findByName("Kort 2", Locale.GERMANY).get(0);
    assertNotNull(medication);

    Disease disease = diseaseService.findByCode("M79.0");
    assertNotNull(disease);

    patientMedicationService.addConsumedMedication(
        patient.getId(), disease.getId(), medication.getId(), 2.0d, new Date(), null);
    assertEquals(oldSize + 1, patientMedicationDao.findAll().size());

    patientMedicationService.addConsumedMedication(
        patient.getId(), disease.getId(), medication.getId(), 2.0d, new Date(), "test");
    assertEquals(oldSize + 2, patientMedicationDao.findAll().size());

    List<Medication> result =
        patientMedicationService.findAllConsumedMedications(patient.getId(), disease.getId());
    assertEquals(4, result.size());
    assertFalse(result.get(0).equals(result.get(1)));

    result = patientMedicationService.findAllConsumedMedications(patient.getId(), 0L);
    assertEquals(0, result.size());
  }