@Test public void testCalculateParacetamolRuleResultUnderagedPatient3() { final long patientAgeInYears = 2L; final double patientWeight = 10.0; final double patientHeight = 150.0; final DateTime actionTimeStamp = new DateTime(2016, 1, 20, 12, 0, 0); final Locale locale = new Locale("en_GB"); final double dailyDosage = 600.0; final ParacetamolRuleResult paracetamolRuleResult = paracetamolRule.calculateRuleResult( dailyDosage, patientWeight, patientAgeInYears, Collections.emptyList(), locale); assertNotNull(paracetamolRuleResult); assertTrue(paracetamolRuleResult.isQuantityOk()); }
ParacetamolRuleResult calculateRuleResult( final double dose, final double patientWeight, final Long patientAge, final List<NamedExternalDto> medications, final Locale locale) { final ParacetamolRuleResult result = new ParacetamolRuleResult(); result.setMedications(medications); final boolean patientUnderaged = isPatientUnderaged(patientAge); final double underageDoseLimit = getUnderageDoseLimit(patientWeight); final boolean underageOverdose = patientUnderaged && dose > underageDoseLimit; final double adultDoseLimit = getAdultDoseLimit(patientWeight); final boolean adultOverdose = dose > adultDoseLimit; result.setQuantityOk(!underageOverdose && !adultOverdose); result.setAdultRulePercentage(Math.ceil(dose / adultDoseLimit * 100)); result.setUnderageRulePercentage(patientUnderaged ? Math.ceil(dose / underageDoseLimit * 100) : null); if (patientUnderaged && result.getUnderageRulePercentage() > result.getAdultRulePercentage()) { result.setRule(getUnderageRuleDescription(locale)); } if (adultOverdose) { result.setRule(getAdultRuleDescription(locale, adultDoseLimit)); } return result; }
ParacetamolRule implements MedicationRule<ParacetamolRuleParameters, ParacetamolRuleResult> { ParacetamolRuleResult calculateRuleResult( final double dose, final double patientWeight, final Long patientAge, final List<NamedExternalDto> medications, final Locale locale) { final ParacetamolRuleResult result = new ParacetamolRuleResult(); result.setMedications(medications); final boolean patientUnderaged = isPatientUnderaged(patientAge); final double underageDoseLimit = getUnderageDoseLimit(patientWeight); final boolean underageOverdose = patientUnderaged && dose > underageDoseLimit; final double adultDoseLimit = getAdultDoseLimit(patientWeight); final boolean adultOverdose = dose > adultDoseLimit; result.setQuantityOk(!underageOverdose && !adultOverdose); result.setAdultRulePercentage(Math.ceil(dose / adultDoseLimit * 100)); result.setUnderageRulePercentage(patientUnderaged ? Math.ceil(dose / underageDoseLimit * 100) : null); if (patientUnderaged && result.getUnderageRulePercentage() > result.getAdultRulePercentage()) { result.setRule(getUnderageRuleDescription(locale)); } if (adultOverdose) { result.setRule(getAdultRuleDescription(locale, adultDoseLimit)); } return result; } }
ParacetamolRule implements MedicationRule<ParacetamolRuleParameters, ParacetamolRuleResult> { ParacetamolRuleResult calculateRuleResult( final double dose, final double patientWeight, final Long patientAge, final List<NamedExternalDto> medications, final Locale locale) { final ParacetamolRuleResult result = new ParacetamolRuleResult(); result.setMedications(medications); final boolean patientUnderaged = isPatientUnderaged(patientAge); final double underageDoseLimit = getUnderageDoseLimit(patientWeight); final boolean underageOverdose = patientUnderaged && dose > underageDoseLimit; final double adultDoseLimit = getAdultDoseLimit(patientWeight); final boolean adultOverdose = dose > adultDoseLimit; result.setQuantityOk(!underageOverdose && !adultOverdose); result.setAdultRulePercentage(Math.ceil(dose / adultDoseLimit * 100)); result.setUnderageRulePercentage(patientUnderaged ? Math.ceil(dose / underageDoseLimit * 100) : null); if (patientUnderaged && result.getUnderageRulePercentage() > result.getAdultRulePercentage()) { result.setRule(getUnderageRuleDescription(locale)); } if (adultOverdose) { result.setRule(getAdultRuleDescription(locale, adultDoseLimit)); } return result; }  }
ParacetamolRule implements MedicationRule<ParacetamolRuleParameters, ParacetamolRuleResult> { ParacetamolRuleResult calculateRuleResult( final double dose, final double patientWeight, final Long patientAge, final List<NamedExternalDto> medications, final Locale locale) { final ParacetamolRuleResult result = new ParacetamolRuleResult(); result.setMedications(medications); final boolean patientUnderaged = isPatientUnderaged(patientAge); final double underageDoseLimit = getUnderageDoseLimit(patientWeight); final boolean underageOverdose = patientUnderaged && dose > underageDoseLimit; final double adultDoseLimit = getAdultDoseLimit(patientWeight); final boolean adultOverdose = dose > adultDoseLimit; result.setQuantityOk(!underageOverdose && !adultOverdose); result.setAdultRulePercentage(Math.ceil(dose / adultDoseLimit * 100)); result.setUnderageRulePercentage(patientUnderaged ? Math.ceil(dose / underageDoseLimit * 100) : null); if (patientUnderaged && result.getUnderageRulePercentage() > result.getAdultRulePercentage()) { result.setRule(getUnderageRuleDescription(locale)); } if (adultOverdose) { result.setRule(getAdultRuleDescription(locale, adultDoseLimit)); } return result; }  @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> { ParacetamolRuleResult calculateRuleResult( final double dose, final double patientWeight, final Long patientAge, final List<NamedExternalDto> medications, final Locale locale) { final ParacetamolRuleResult result = new ParacetamolRuleResult(); result.setMedications(medications); final boolean patientUnderaged = isPatientUnderaged(patientAge); final double underageDoseLimit = getUnderageDoseLimit(patientWeight); final boolean underageOverdose = patientUnderaged && dose > underageDoseLimit; final double adultDoseLimit = getAdultDoseLimit(patientWeight); final boolean adultOverdose = dose > adultDoseLimit; result.setQuantityOk(!underageOverdose && !adultOverdose); result.setAdultRulePercentage(Math.ceil(dose / adultDoseLimit * 100)); result.setUnderageRulePercentage(patientUnderaged ? Math.ceil(dose / underageDoseLimit * 100) : null); if (patientUnderaged && result.getUnderageRulePercentage() > result.getAdultRulePercentage()) { result.setRule(getUnderageRuleDescription(locale)); } if (adultOverdose) { result.setRule(getAdultRuleDescription(locale, adultDoseLimit)); } return result; }  @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);  }