ProfileDTO userDTO) {
		User user = userService.findById(userDTO.getId());
		user.setFirstName(userDTO.getFirstName());
		user.setLastName(userDTO.getLastName());
		user.setAddress(userDTO.getAddress());
		user.setCity(userDTO.getCity());
		user.setPhoneNumber(userDTO.getPhone());
		userService.saveUser(user);
	}

	@GetMapping(value = "/logged")
	@PreAuthorize("hasRole('PATIENT')" + "||" + "hasRole('PHARMACY_ADMIN')" + "||" + "hasRole('ROLE_DERMATOLOGIST')"
			+ "||" + "hasRole('ROLE_PHARMACIST')" + "||" + "hasRole('SYSTEM_ADMIN')" + "||" + "hasRole('DEALER')")
	public UserProfileDTO getLoggedPatient() {
		Authentication auth = SecurityContextHolder.getContext().getAuthentication();
		User user = (User) auth.getPrincipal();

		UserProfileDTO userDTO = new UserProfileDTO(user.getId(), user.getEmail(), user.getFirstName(),
				user.getLastName(), user.getAddress(), user.getCity(), user.getState(), user.getPhoneNumber());

		if (user.getUserType() == UserType.PATIENT) {
			Patient p = (Patient) auth.getPrincipal();
			List<CategoryType> cts = promotionService.getPatientType(p.getPoints());
			double discount = 0;
			String category = "";
			if (cts == null || cts.size() == 0) {
				category = "NO TYPE";
			} else {
				CategoryType ct = cts.get(cts.size() - 1);
				discount = promotionService.getDiscount(ct);
				category = ct.toString();
			}

			PatientProfileDTO patientDTO = new PatientProfileDTO(p.getId(), p.getEmail(), p.getFirstName(),
					p.getLastName(), p.getAddress(), p.getCity(), p.getState(), p.getPhoneNumber(), p.getPoints(),
					category, discount, p.getPenalties());
			return patientDTO;
		} else if (user.getUserType() == UserType.PHARMACY_ADMIN) {
			PharmacyAdmin pa = (PharmacyAdmin) auth.getPrincipal();
			PharmacyAdminProfileDTO pharmacyAdminDTO = new PharmacyAdminProfileDTO(pa.getId(), pa.getEmail(),
					pa.getFirstName(), pa.getLastName(), pa.getAddress(), pa.getCity(), pa.getState(),
					pa.getPhoneNumber(), pa.getPharmacy().getId());
			return pharmacyAdminDTO;
		}

		return userDTO;
	}

	@GetMapping(value = "/pharmacists")
	@PreAuthorize("hasRole('PATIENT')" + "||" + "hasRole('PHARMACY_ADMIN')")
	public List<HealthWorkerDTO> getAllPharmacistsByFirstAndLastName(@RequestParam("firstName") String firstName,
			@RequestParam("lastName") String lastName, Authentication authentication) {
		User loggedUser = (User) authentication.getPrincipal();
		return userService.getAllPharmacistsByFirstAndLastName(firstName, lastName, loggedUser.getEmail());
	}

	@GetMapping(value = "/patients/search")
	@PreAuthorize("hasRole('ROLE_DERMATOLOGIST')" + "||" + "hasRole('ROLE_PHARMACIST')")
	public List<SearchedPatientDTO> searchPatient(@RequestParam("firstName") String firstName,
			@RequestParam("lastName") String lastName) {
		return userService.searchPatient(firstName, lastName);
	}

	@GetMapping(value = "/dermatologists")
	@PreAuthorize("hasRole('PATIENT')" + "||" + "hasRole('PHARMACY_ADMIN')")

	public List<HealthWorkerDTO> getAllDermatologistsByFirstAndLastName(@RequestParam("firstName") String firstName,
			@RequestParam("lastName") String lastName, Authentication authentication) {
		User loggedUser = (User) authentication.getPrincipal();
		return userService.getAllDermatologistsByFirstAndLastName(firstName, lastName, loggedUser.getEmail());

	}

	@PostMapping(value = "/registerElevatedUser")
	@PreAuthorize("hasRole('SYSTEM_ADMIN')")
	public User registerElevatedUser(@RequestBody NewElevatedUserRequestDTO udto) {
		if (udto.getUserType().equalsIgnoreCase("PHARMACY_ADMIN"))
			return this.userService.createPharmacyAdmin(udto);
		else if (udto.getUserType().equalsIgnoreCase("DEALER"))
			return this.userService.createDealer(udto);
		else if (udto.getUserType().equalsIgnoreCase("DERMATOLOGIST"))
			return this.userService.createDermatologist(udto);
		else if (udto.getUserType().equalsIgnoreCase("SYSTEM_ADMIN"))
			return this.userService.createSystemAdmin(udto);
		else
			return null;
	}

	@PostMapping(value = "/checkPassword")
	@PreAuthorize("hasRole('PATIENT')" + "||" + "hasRole('PHARMACY_ADMIN')" + "||" + "hasRole('ROLE_DERMATOLOGIST')"
			+ "||" + "hasRole('ROLE_PHARMACIST')" + "||" + "hasRole('SYSTEM_ADMIN')" + "||" + "hasRole('DEALER')")
	public boolean checkPassword(@RequestBody StringInformationDTO sidto) {
		Authentication auth = SecurityContextHolder.getContext().getAuthentication();
		User user = (User) auth.getPrincipal();
		return passwordEncoder.matches(sidto.getInfo(), user.getPassword());
	}

	@PostMapping(value = "/changePassword")
	@PreAuthorize("hasRole('PATIENT')" + "||" + "hasRole('PHARMACY_ADMIN')" + "||" + "hasRole('ROLE_DERMATOLOGIST')"
			+ "||" + "hasRole('ROLE_PHARMACIST')" + "||" + "hasRole('SYSTEM_ADMIN')" + "||" + "hasRole('DEALER')")
	public void changePassword(@RequestBody StringInformationDTO sidto, Authentication auth) {
		userService.changePassword(((User) auth.getPrincipal()).getId(), passwordEncoder.encode(sidto.getInfo()));
	}
	
	@GetMapping(value ="/myAllergies")
	@PreAuthorize("hasRole('PATIENT')")
	public List<Long> getPatientAllergiesIds(){
		Authentication auth = SecurityContextHolder.getContext().getAuthentication();
		User user = (User) auth.getPrincipal();
		return userService.getPatientAllergiesIds(user.getId());
	}

	@GetMapping("/free-pharmacists")
	@PreAuthorize("hasRole('PHARMACY_ADMIN')")
	public List<CredentialsAndIdDTO> getAllFreePharmacists() {
		return userService.getAllFreePharmacists();
	}

	@GetMapping(value = "/dermatologists-not-in-pharmacy")
	@PreAuthorize("hasRole('PHARMACY_ADMIN')")
	public List<CredentialsAndIdDTO> getDermatologistsWhoAreNotInPharmacy(Authentication auth) {
		User user = (User) auth.getPrincipal();
		return userService.getDermatologistsWhoAreNotInPharmacy(user.getId());
	}
	
	@GetMapping(value ="/patient-allergies-ids/{id}")
	public List<Long> getPatientAllergiesIds(@PathVariable("id") Long patientId){
		return userService.getPatientAllergiesIds(patientId);
	}
	
	@GetMapping(value = "/myerecipes")
	@PreAuthorize("hasRole('PATIENT')")
	public List<PatientsERecipeDTO> getMyERecipes(Authentication auth) {
		User user = (User) auth.getPrincipal();
		return eRecipeService.getPatientsERecipes(user