public MedicamentsInDisease getMedicamentsInDisease(HttpServletRequest request, Disease disease) { User user = userService.findWithMedicaments(request); if (!disease.getUser().equals(user)) throw new AccessDeniedException(); List<Medicament> medicaments = diseaseMedicamentRepositoryEntityGraph.findWithDisease(disease); return new MedicamentsInDisease(user, medicaments); }
public List<Dosage> findDosages(Disease disease) { Set<Dosage> dosages = new HashSet<Dosage>(); List<DiseaseMedicament> diseaseMedicaments = diseaseMedicamentRepositoryEntityGraph.findWithDosagesAndMedicament(disease); for (DiseaseMedicament diseaseMedicament : diseaseMedicaments) { dosages.addAll(diseaseMedicament.getDosages()); } List<Dosage> returnDosages = new ArrayList<Dosage>(dosages); Collections.sort(returnDosages); return returnDosages; }
public DiseaseMedicament finOne(Disease disease, Medicament medicament) { return diseaseMedicamentRepositoryEntityGraph.findOneWithDosages(medicament, disease); }
public Set<Dosage> find(Disease disease, Medicament medicament) { DiseaseMedicament diseaseMedicament = diseaseMedicamentRepositoryEntityGraph.findOneWithDosages(medicament, disease); return diseaseMedicament.getDosages(); }