@Test(expected = NullPointerException.class) public void testApplyRuleForTherapiesNoNullParameters3() throws Exception { final ParacetamolRuleForTherapiesParameters parameters = new ParacetamolRuleForTherapiesParameters(); parameters.setMedicationParacetamolRuleType(MedicationParacetamolRuleType.FOR_THERAPIES); parameters.setPatientId("1"); parameters.setTherapies(Collections.emptyList()); final ParacetamolRuleResult paracetamolRuleResult = paracetamolRule.applyRule( parameters, new DateTime(), new Locale("si Sl")); }
@Override public ParacetamolRuleResult applyRule( @Nonnull final ParacetamolRuleParameters parameters, @Nonnull final DateTime actionTimestamp, @Nonnull final Locale locale) { Preconditions.checkNotNull(parameters, "parameters must not be null"); Preconditions.checkNotNull(actionTimestamp, "actionTimestamp must not be null"); Preconditions.checkNotNull(locale, "locale must not be null"); final MedicationParacetamolRuleType medicationParacetamolRuleType = parameters.getMedicationParacetamolRuleType(); if (medicationParacetamolRuleType == MedicationParacetamolRuleType.FOR_THERAPY) { final TherapyDto therapyDto = ((ParacetamolRuleForTherapyParameters)parameters).getTherapyDto(); final List<MedicationDataDto> medicationDataDtoList = ((ParacetamolRuleForTherapyParameters)parameters).getMedicationDataDtoList(); Preconditions.checkNotNull(therapyDto, "therapyDto must not be null"); Preconditions.checkNotNull(medicationDataDtoList, "medicationDataDtoList must not be null"); Preconditions.checkArgument(!medicationDataDtoList.isEmpty(), "medicationDataDtoList must not be empty"); return applyRuleForTherapy( therapyDto, medicationDataDtoList, parameters.getPatientWeight(), parameters.getPatientAgeInYears(), locale); } else if (medicationParacetamolRuleType == MedicationParacetamolRuleType.FOR_THERAPIES) { final List<TherapyDto> therapies = ((ParacetamolRuleForTherapiesParameters)parameters).getTherapies(); final Interval searchInterval = ((ParacetamolRuleForTherapiesParameters)parameters).getSearchInterval(); final String patientId = ((ParacetamolRuleForTherapiesParameters)parameters).getPatientId(); Preconditions.checkNotNull(therapies, "therapies must not be null"); Preconditions.checkNotNull(searchInterval, "searchInterval must not be null"); Preconditions.checkNotNull(patientId, "patientId must not be null"); return applyRuleForTherapies( therapies, parameters.getPatientWeight(), parameters.getPatientAgeInYears(), actionTimestamp, patientId, locale); } else if (medicationParacetamolRuleType == MedicationParacetamolRuleType.FOR_ADMINISTRATION) { final TherapyDoseDto therapyDoseDto = ((ParacetamolRuleForAdministrationParameters)parameters).getTherapyDoseDto(); final String administrationId = ((ParacetamolRuleForAdministrationParameters)parameters).getAdministrationId(); final String taskId = ((ParacetamolRuleForAdministrationParameters)parameters).getTaskId(); final TherapyDto therapyDto = ((ParacetamolRuleForAdministrationParameters)parameters).getTherapyDto(); final Interval searchInterval = ((ParacetamolRuleForAdministrationParameters)parameters).getSearchInterval(); final String patientId = ((ParacetamolRuleForAdministrationParameters)parameters).getPatientId(); Preconditions.checkNotNull(searchInterval, "searchInterval must not be null"); Preconditions.checkNotNull(patientId, "patientId must not be null"); return applyRuleForAdministration( therapyDoseDto, administrationId, taskId, therapyDto, parameters.getPatientWeight(), parameters.getPatientAgeInYears(), searchInterval, actionTimestamp, patientId, locale); } else { throw new IllegalArgumentException("Not supported medication paracetamol rule type"); } }
ParacetamolRule implements MedicationRule<ParacetamolRuleParameters, ParacetamolRuleResult> { @Override public ParacetamolRuleResult applyRule( @Nonnull final ParacetamolRuleParameters parameters, @Nonnull final DateTime actionTimestamp, @Nonnull final Locale locale) { Preconditions.checkNotNull(parameters, "parameters must not be null"); Preconditions.checkNotNull(actionTimestamp, "actionTimestamp must not be null"); Preconditions.checkNotNull(locale, "locale must not be null"); final MedicationParacetamolRuleType medicationParacetamolRuleType = parameters.getMedicationParacetamolRuleType(); if (medicationParacetamolRuleType == MedicationParacetamolRuleType.FOR_THERAPY) { final TherapyDto therapyDto = ((ParacetamolRuleForTherapyParameters)parameters).getTherapyDto(); final List<MedicationDataDto> medicationDataDtoList = ((ParacetamolRuleForTherapyParameters)parameters).getMedicationDataDtoList(); Preconditions.checkNotNull(therapyDto, "therapyDto must not be null"); Preconditions.checkNotNull(medicationDataDtoList, "medicationDataDtoList must not be null"); Preconditions.checkArgument(!medicationDataDtoList.isEmpty(), "medicationDataDtoList must not be empty"); return applyRuleForTherapy( therapyDto, medicationDataDtoList, parameters.getPatientWeight(), parameters.getPatientAgeInYears(), locale); } else if (medicationParacetamolRuleType == MedicationParacetamolRuleType.FOR_THERAPIES) { final List<TherapyDto> therapies = ((ParacetamolRuleForTherapiesParameters)parameters).getTherapies(); final Interval searchInterval = ((ParacetamolRuleForTherapiesParameters)parameters).getSearchInterval(); final String patientId = ((ParacetamolRuleForTherapiesParameters)parameters).getPatientId(); Preconditions.checkNotNull(therapies, "therapies must not be null"); Preconditions.checkNotNull(searchInterval, "searchInterval must not be null"); Preconditions.checkNotNull(patientId, "patientId must not be null"); return applyRuleForTherapies( therapies, parameters.getPatientWeight(), parameters.getPatientAgeInYears(), actionTimestamp, patientId, locale); } else if (medicationParacetamolRuleType == MedicationParacetamolRuleType.FOR_ADMINISTRATION) { final TherapyDoseDto therapyDoseDto = ((ParacetamolRuleForAdministrationParameters)parameters).getTherapyDoseDto(); final String administrationId = ((ParacetamolRuleForAdministrationParameters)parameters).getAdministrationId(); final String taskId = ((ParacetamolRuleForAdministrationParameters)parameters).getTaskId(); final TherapyDto therapyDto = ((ParacetamolRuleForAdministrationParameters)parameters).getTherapyDto(); final Interval searchInterval = ((ParacetamolRuleForAdministrationParameters)parameters).getSearchInterval(); final String patientId = ((ParacetamolRuleForAdministrationParameters)parameters).getPatientId(); Preconditions.checkNotNull(searchInterval, "searchInterval must not be null"); Preconditions.checkNotNull(patientId, "patientId must not be null"); return applyRuleForAdministration( therapyDoseDto, administrationId, taskId, therapyDto, parameters.getPatientWeight(), parameters.getPatientAgeInYears(), searchInterval, actionTimestamp, patientId, locale); } else { throw new IllegalArgumentException("Not supported medication paracetamol rule type"); } } }
ParacetamolRule implements MedicationRule<ParacetamolRuleParameters, ParacetamolRuleResult> { @Override public ParacetamolRuleResult applyRule( @Nonnull final ParacetamolRuleParameters parameters, @Nonnull final DateTime actionTimestamp, @Nonnull final Locale locale) { Preconditions.checkNotNull(parameters, "parameters must not be null"); Preconditions.checkNotNull(actionTimestamp, "actionTimestamp must not be null"); Preconditions.checkNotNull(locale, "locale must not be null"); final MedicationParacetamolRuleType medicationParacetamolRuleType = parameters.getMedicationParacetamolRuleType(); if (medicationParacetamolRuleType == MedicationParacetamolRuleType.FOR_THERAPY) { final TherapyDto therapyDto = ((ParacetamolRuleForTherapyParameters)parameters).getTherapyDto(); final List<MedicationDataDto> medicationDataDtoList = ((ParacetamolRuleForTherapyParameters)parameters).getMedicationDataDtoList(); Preconditions.checkNotNull(therapyDto, "therapyDto must not be null"); Preconditions.checkNotNull(medicationDataDtoList, "medicationDataDtoList must not be null"); Preconditions.checkArgument(!medicationDataDtoList.isEmpty(), "medicationDataDtoList must not be empty"); return applyRuleForTherapy( therapyDto, medicationDataDtoList, parameters.getPatientWeight(), parameters.getPatientAgeInYears(), locale); } else if (medicationParacetamolRuleType == MedicationParacetamolRuleType.FOR_THERAPIES) { final List<TherapyDto> therapies = ((ParacetamolRuleForTherapiesParameters)parameters).getTherapies(); final Interval searchInterval = ((ParacetamolRuleForTherapiesParameters)parameters).getSearchInterval(); final String patientId = ((ParacetamolRuleForTherapiesParameters)parameters).getPatientId(); Preconditions.checkNotNull(therapies, "therapies must not be null"); Preconditions.checkNotNull(searchInterval, "searchInterval must not be null"); Preconditions.checkNotNull(patientId, "patientId must not be null"); return applyRuleForTherapies( therapies, parameters.getPatientWeight(), parameters.getPatientAgeInYears(), actionTimestamp, patientId, locale); } else if (medicationParacetamolRuleType == MedicationParacetamolRuleType.FOR_ADMINISTRATION) { final TherapyDoseDto therapyDoseDto = ((ParacetamolRuleForAdministrationParameters)parameters).getTherapyDoseDto(); final String administrationId = ((ParacetamolRuleForAdministrationParameters)parameters).getAdministrationId(); final String taskId = ((ParacetamolRuleForAdministrationParameters)parameters).getTaskId(); final TherapyDto therapyDto = ((ParacetamolRuleForAdministrationParameters)parameters).getTherapyDto(); final Interval searchInterval = ((ParacetamolRuleForAdministrationParameters)parameters).getSearchInterval(); final String patientId = ((ParacetamolRuleForAdministrationParameters)parameters).getPatientId(); Preconditions.checkNotNull(searchInterval, "searchInterval must not be null"); Preconditions.checkNotNull(patientId, "patientId must not be null"); return applyRuleForAdministration( therapyDoseDto, administrationId, taskId, therapyDto, parameters.getPatientWeight(), parameters.getPatientAgeInYears(), searchInterval, actionTimestamp, patientId, locale); } else { throw new IllegalArgumentException("Not supported medication paracetamol rule type"); } }  }
ParacetamolRule implements MedicationRule<ParacetamolRuleParameters, ParacetamolRuleResult> { @Override public ParacetamolRuleResult applyRule( @Nonnull final ParacetamolRuleParameters parameters, @Nonnull final DateTime actionTimestamp, @Nonnull final Locale locale) { Preconditions.checkNotNull(parameters, "parameters must not be null"); Preconditions.checkNotNull(actionTimestamp, "actionTimestamp must not be null"); Preconditions.checkNotNull(locale, "locale must not be null"); final MedicationParacetamolRuleType medicationParacetamolRuleType = parameters.getMedicationParacetamolRuleType(); if (medicationParacetamolRuleType == MedicationParacetamolRuleType.FOR_THERAPY) { final TherapyDto therapyDto = ((ParacetamolRuleForTherapyParameters)parameters).getTherapyDto(); final List<MedicationDataDto> medicationDataDtoList = ((ParacetamolRuleForTherapyParameters)parameters).getMedicationDataDtoList(); Preconditions.checkNotNull(therapyDto, "therapyDto must not be null"); Preconditions.checkNotNull(medicationDataDtoList, "medicationDataDtoList must not be null"); Preconditions.checkArgument(!medicationDataDtoList.isEmpty(), "medicationDataDtoList must not be empty"); return applyRuleForTherapy( therapyDto, medicationDataDtoList, parameters.getPatientWeight(), parameters.getPatientAgeInYears(), locale); } else if (medicationParacetamolRuleType == MedicationParacetamolRuleType.FOR_THERAPIES) { final List<TherapyDto> therapies = ((ParacetamolRuleForTherapiesParameters)parameters).getTherapies(); final Interval searchInterval = ((ParacetamolRuleForTherapiesParameters)parameters).getSearchInterval(); final String patientId = ((ParacetamolRuleForTherapiesParameters)parameters).getPatientId(); Preconditions.checkNotNull(therapies, "therapies must not be null"); Preconditions.checkNotNull(searchInterval, "searchInterval must not be null"); Preconditions.checkNotNull(patientId, "patientId must not be null"); return applyRuleForTherapies( therapies, parameters.getPatientWeight(), parameters.getPatientAgeInYears(), actionTimestamp, patientId, locale); } else if (medicationParacetamolRuleType == MedicationParacetamolRuleType.FOR_ADMINISTRATION) { final TherapyDoseDto therapyDoseDto = ((ParacetamolRuleForAdministrationParameters)parameters).getTherapyDoseDto(); final String administrationId = ((ParacetamolRuleForAdministrationParameters)parameters).getAdministrationId(); final String taskId = ((ParacetamolRuleForAdministrationParameters)parameters).getTaskId(); final TherapyDto therapyDto = ((ParacetamolRuleForAdministrationParameters)parameters).getTherapyDto(); final Interval searchInterval = ((ParacetamolRuleForAdministrationParameters)parameters).getSearchInterval(); final String patientId = ((ParacetamolRuleForAdministrationParameters)parameters).getPatientId(); Preconditions.checkNotNull(searchInterval, "searchInterval must not be null"); Preconditions.checkNotNull(patientId, "patientId must not be null"); return applyRuleForAdministration( therapyDoseDto, administrationId, taskId, therapyDto, parameters.getPatientWeight(), parameters.getPatientAgeInYears(), searchInterval, actionTimestamp, patientId, locale); } else { throw new IllegalArgumentException("Not supported medication paracetamol rule type"); } }  @Required void setMedicationsOpenEhrDao(final MedicationsOpenEhrDao medicationsOpenEhrDao); @Required void setMedicationsDao(final MedicationsDao medicationsDao); @Required void setMedicationsBo(final MedicationsBo medicationsBo); @Required void setMedicationsTasksProvider(final MedicationsTasksProvider medicationsTasksProvider); @Required void setMedicationDataProvider(final MedicationFromEhrConverter.MedicationDataProvider medicationDataProvider); @Required void setMedicationsValueHolder(final ValueHolder<Map<Long, MedicationHolderDto>> medicationsValueHolder); @Required void setIngredientCalculator(final IngredientCalculator ingredientCalculator); @Required void setAdministrationFromEhrConverter(final AdministrationFromEhrConverter administrationFromEhrConverter); @Required void setAdministrationUtils(final AdministrationUtils administrationUtils); @Override ParacetamolRuleResult applyRule(
      @Nonnull final ParacetamolRuleParameters parameters,
      @Nonnull final DateTime actionTimestamp,
      @Nonnull final Locale locale); }
ParacetamolRule implements MedicationRule<ParacetamolRuleParameters, ParacetamolRuleResult> { @Override public ParacetamolRuleResult applyRule( @Nonnull final ParacetamolRuleParameters parameters, @Nonnull final DateTime actionTimestamp, @Nonnull final Locale locale) { Preconditions.checkNotNull(parameters, "parameters must not be null"); Preconditions.checkNotNull(actionTimestamp, "actionTimestamp must not be null"); Preconditions.checkNotNull(locale, "locale must not be null"); final MedicationParacetamolRuleType medicationParacetamolRuleType = parameters.getMedicationParacetamolRuleType(); if (medicationParacetamolRuleType == MedicationParacetamolRuleType.FOR_THERAPY) { final TherapyDto therapyDto = ((ParacetamolRuleForTherapyParameters)parameters).getTherapyDto(); final List<MedicationDataDto> medicationDataDtoList = ((ParacetamolRuleForTherapyParameters)parameters).getMedicationDataDtoList(); Preconditions.checkNotNull(therapyDto, "therapyDto must not be null"); Preconditions.checkNotNull(medicationDataDtoList, "medicationDataDtoList must not be null"); Preconditions.checkArgument(!medicationDataDtoList.isEmpty(), "medicationDataDtoList must not be empty"); return applyRuleForTherapy( therapyDto, medicationDataDtoList, parameters.getPatientWeight(), parameters.getPatientAgeInYears(), locale); } else if (medicationParacetamolRuleType == MedicationParacetamolRuleType.FOR_THERAPIES) { final List<TherapyDto> therapies = ((ParacetamolRuleForTherapiesParameters)parameters).getTherapies(); final Interval searchInterval = ((ParacetamolRuleForTherapiesParameters)parameters).getSearchInterval(); final String patientId = ((ParacetamolRuleForTherapiesParameters)parameters).getPatientId(); Preconditions.checkNotNull(therapies, "therapies must not be null"); Preconditions.checkNotNull(searchInterval, "searchInterval must not be null"); Preconditions.checkNotNull(patientId, "patientId must not be null"); return applyRuleForTherapies( therapies, parameters.getPatientWeight(), parameters.getPatientAgeInYears(), actionTimestamp, patientId, locale); } else if (medicationParacetamolRuleType == MedicationParacetamolRuleType.FOR_ADMINISTRATION) { final TherapyDoseDto therapyDoseDto = ((ParacetamolRuleForAdministrationParameters)parameters).getTherapyDoseDto(); final String administrationId = ((ParacetamolRuleForAdministrationParameters)parameters).getAdministrationId(); final String taskId = ((ParacetamolRuleForAdministrationParameters)parameters).getTaskId(); final TherapyDto therapyDto = ((ParacetamolRuleForAdministrationParameters)parameters).getTherapyDto(); final Interval searchInterval = ((ParacetamolRuleForAdministrationParameters)parameters).getSearchInterval(); final String patientId = ((ParacetamolRuleForAdministrationParameters)parameters).getPatientId(); Preconditions.checkNotNull(searchInterval, "searchInterval must not be null"); Preconditions.checkNotNull(patientId, "patientId must not be null"); return applyRuleForAdministration( therapyDoseDto, administrationId, taskId, therapyDto, parameters.getPatientWeight(), parameters.getPatientAgeInYears(), searchInterval, actionTimestamp, patientId, locale); } else { throw new IllegalArgumentException("Not supported medication paracetamol rule type"); } }  @Required void setMedicationsOpenEhrDao(final MedicationsOpenEhrDao medicationsOpenEhrDao); @Required void setMedicationsDao(final MedicationsDao medicationsDao); @Required void setMedicationsBo(final MedicationsBo medicationsBo); @Required void setMedicationsTasksProvider(final MedicationsTasksProvider medicationsTasksProvider); @Required void setMedicationDataProvider(final MedicationFromEhrConverter.MedicationDataProvider medicationDataProvider); @Required void setMedicationsValueHolder(final ValueHolder<Map<Long, MedicationHolderDto>> medicationsValueHolder); @Required void setIngredientCalculator(final IngredientCalculator ingredientCalculator); @Required void setAdministrationFromEhrConverter(final AdministrationFromEhrConverter administrationFromEhrConverter); @Required void setAdministrationUtils(final AdministrationUtils administrationUtils); @Override ParacetamolRuleResult applyRule(
      @Nonnull final ParacetamolRuleParameters parameters,
      @Nonnull final DateTime actionTimestamp,
      @Nonnull final Locale locale);  }