public int checkVal() {
   Doctor doctor = doctorService.get(Long.parseLong(doctorID));
   SessionPayment sp = spService.getSpExistPatient(id);
   int sessionVal = 0;
   for (DoctorSession ds : sp.getListOfSession()) {
     if (ds.getDoctor().getId() == doctor.getId()) {
       sessionVal += ds.getSum();
     }
   }
   int paymentVal = 0;
   for (Payment p : sp.getListOfPayment()) {
     Doctor doctor1 = paymentService.get(p.getId()).getDoctor();
     if (doctor1 != null)
       if (doctor1.getId() == doctor.getId()) {
         paymentVal += p.getValue();
       }
   }
   return sessionVal - paymentVal;
 }
 public void prepare() throws Exception {
   if ((payment != null) && payment.getId() != null) {
     this.payment = paymentService.get(payment.getId());
     this.paymentHash = payment.hashCode();
   }
 }