public void create(Patients patients) throws RollbackFailureException, Exception {
		if (patients.getConsultsCollection() == null) {
			patients.setConsultsCollection(new ArrayList<Consults>());
		}
		EntityManager em = null;
		try {
			utx.begin();
			em = getEntityManager();
			Collection<Consults> attachedConsultsCollection = new ArrayList<Consults>();
			for (Consults consultsCollectionConsultsToAttach : patients.getConsultsCollection()) {
				consultsCollectionConsultsToAttach = em.getReference(consultsCollectionConsultsToAttach.getClass(), consultsCollectionConsultsToAttach.getId());
				attachedConsultsCollection.add(consultsCollectionConsultsToAttach);
			}
			patients.setConsultsCollection(attachedConsultsCollection);
			em.persist(patients);
			for (Consults consultsCollectionConsults : patients.getConsultsCollection()) {
				Patients oldIdPatientOfConsultsCollectionConsults = consultsCollectionConsults.getIdPatient();
				consultsCollectionConsults.setIdPatient(patients);
				consultsCollectionConsults = em.merge(consultsCollectionConsults);
				if (oldIdPatientOfConsultsCollectionConsults != null) {
					oldIdPatientOfConsultsCollectionConsults.getConsultsCollection().remove(consultsCollectionConsults);
					oldIdPatientOfConsultsCollectionConsults = em.merge(oldIdPatientOfConsultsCollectionConsults);
				}
			}
			utx.commit();
		} catch (Exception ex) {
			try {
				utx.rollback();
			} catch (Exception re) {
				throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
			}
			throw ex;
		} finally {
			if (em != null) {
				em.close();
			}
		}
	}