Cambiadas todas las listas deplegables fijas, a listas con búsqueda AJAX

integrada (Estilo typeahead). Permite búsquedas en tiempo real.
* Se muestra información organizada por columnas de datos.
* Identificadores basados en Ids autogenerados.
* Nuevos métodos en EJB común para poder realizar búsquedas de datos con
filtro y paginadas (para los comboBox).
* Varias correcciones de interfaz de usuario.
* Nueva clase de utilidades.
This commit is contained in:
Marcos Garcia Nuñez
2019-12-11 00:37:26 +01:00
parent 1be6cfd72c
commit 3e315f866a
25 changed files with 607 additions and 335 deletions

View File

@@ -26,13 +26,13 @@ public class FamilyDoctorTO implements Serializable {
}
public FamilyDoctorTO(Integer id, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterTO phc) {
this.setId(id);
this.setNif(nif);
this.setName(name);
this.setSurname(surname);
this.setPassword(password);
this.setEmail(email);
this.setPrimaryHealthCareCenter(phc);
this.id = id;
this.nif = nif;
this.name = name;
this.surname = surname;
this.password = password;
this.email =email;
this.primaryHealthCareCenter = phc;
}
public String getEmail() {
@@ -83,7 +83,7 @@ public class FamilyDoctorTO implements Serializable {
this.id = id;
}
public String getDisplayDescription() {
public String getDisplayName() {
return String.format("[%d] %s %s", this.id, this.name, this.surname);
}

View File

@@ -13,7 +13,7 @@ import javax.xml.bind.annotation.XmlRootElement;
public class MedicalSpecialtyTO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
private String name;
private String description;
@@ -21,11 +21,20 @@ public class MedicalSpecialtyTO implements Serializable {
super();
}
public MedicalSpecialtyTO(String name, String description) {
public MedicalSpecialtyTO(Integer id, String name, String description) {
this.id = id;
this.name = name;
this.description = description;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
@@ -42,7 +51,7 @@ public class MedicalSpecialtyTO implements Serializable {
this.description = description;
}
public String getDisplayDescription() {
public String getDisplayName() {
return String.format("[%s] %s", this.name, this.description);
}

View File

@@ -31,13 +31,13 @@ public class PatientTO implements Serializable {
}
public PatientTO(Integer id, String nif, String name, String surname, String password, String email, FamilyDoctorTO familyDoc) {
this.setId(id);
this.setNif(nif);
this.setName(name);
this.setSurname(surname);
this.setPassword(password);
this.setEmail(email);
this.setFamilyDoctor(familyDoc);
this.id = id;
this.nif = nif;
this.name = name;
this.surname = surname;
this.password = password;
this.email =email;
this.familyDoctor = familyDoc;
}
public String getEmail() {

View File

@@ -13,20 +13,28 @@ import javax.xml.bind.annotation.XmlRootElement;
public class PrimaryHealthCareCenterTO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
private String name;
private String location;
public PrimaryHealthCareCenterTO() {
super();
}
public PrimaryHealthCareCenterTO(String name, String location) {
public PrimaryHealthCareCenterTO(Integer Id, String name, String location) {
this.id = Id;
this.name = name;
this.location = location;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
@@ -39,16 +47,16 @@ public class PrimaryHealthCareCenterTO implements Serializable {
return location;
}
public void setLocation(String description) {
this.location = description;
public void setLocation(String value) {
this.location = value;
}
public String getDisplayDescription() {
public String getDisplayName() {
return String.format("[%s] %s", this.name, this.location);
}
@Override
public String toString() {
return String.format("%s[name=%s]", getClass().getSimpleName(), this.getName());
return String.format("%s[name=%s]", getClass().getSimpleName(), this.getName());
}
}

View File

@@ -26,13 +26,13 @@ public class SpecialistDoctorTO implements Serializable {
}
public SpecialistDoctorTO(Integer id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO medicalSpec) {
this.setId(id);
this.setNif(nif);
this.setName(name);
this.setSurname(surname);
this.setPassword(password);
this.setEmail(email);
this.setMedicalSpecialty(medicalSpec);
this.id = id;
this.nif = nif;
this.name = name;
this.surname = surname;
this.password = password;
this.email =email;
this.medicalSpecialty = medicalSpec;
}
public String getEmail() {

View File

@@ -0,0 +1,5 @@
package common;
public class Constants {
public static final int MAX_ITEMS_AUTOCOMPLETE_SEARCH = 200;
}

View File

@@ -0,0 +1,11 @@
package common;
import java.text.Normalizer;
public class Utils {
public static String stripAccents(String input){
return input == null ? null :
Normalizer.normalize(input, Normalizer.Form.NFD)
.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
}
}

View File

@@ -2,17 +2,20 @@ package ejb.common;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import TO.FamilyDoctorTO;
import TO.MedicalSpecialtyTO;
import TO.PatientTO;
import TO.PrimaryHealthCareCenterTO;
import TO.SpecialistDoctorTO;
import common.Utils;
import jpa.FamilyDoctorJPA;
import jpa.MedicalSpecialtyJPA;
import jpa.PatientJPA;
@@ -28,8 +31,8 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
/**
* Metodo que devuelve todas las especialidades medicas
*/
public Collection<MedicalSpecialtyTO> listAllMedicalSpecialities() {
return this.listPagedMedicalSpecialities(0, 0);
public List<MedicalSpecialtyTO> listAllMedicalSpecialities() {
return this.listMedicalSpecialitiesPaged(0, 0);
}
/**
@@ -39,54 +42,106 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
* cada página
*
*/
public Collection<MedicalSpecialtyTO> listPagedMedicalSpecialities(int pageNumber, int pageSize) {
Query query = entman.createQuery("from MedicalSpecialtyJPA order by name");
public List<MedicalSpecialtyTO> listMedicalSpecialitiesPaged(int pageNumber, int pageSize) {
return listMedicalSpecialitiesFiltered(null, pageNumber, pageSize);
}
public List<MedicalSpecialtyTO> listMedicalSpecialitiesFiltered(String searchTerm, int pageNumber, int pageSize) {
String strQuery = "SELECT ms from MedicalSpecialtyJPA ms %s order by ms.name, ms.description";
String strFilter = "";
if (searchTerm == null)
searchTerm = "";
else
searchTerm = Utils.stripAccents(searchTerm).toLowerCase();
if (searchTerm.length() > 0) {
strFilter = "WHERE lower(ms.name) LIKE :searchTerm OR lower(ms.description) LIKE :searchTerm";
}
TypedQuery<MedicalSpecialtyJPA> query = entman.createQuery(String.format(strQuery, strFilter), MedicalSpecialtyJPA.class);
if (searchTerm.length() > 0)
query.setParameter("searchTerm", "%" + searchTerm + "%");
if (pageSize > 0) {
query.setFirstResult(pageNumber * pageSize);
query.setMaxResults(pageSize);
}
@SuppressWarnings("unchecked")
Collection<MedicalSpecialtyJPA> allJPA = query.getResultList();
Collection<MedicalSpecialtyTO> allSpecialities = new ArrayList<MedicalSpecialtyTO>();
List<MedicalSpecialtyJPA> allJPA = query.getResultList();
List<MedicalSpecialtyTO> allSpecialities = new ArrayList<MedicalSpecialtyTO>();
for (MedicalSpecialtyJPA ms : allJPA) {
allSpecialities.add(new MedicalSpecialtyTO(ms.getName(), ms.getDescription()));
for (MedicalSpecialtyJPA cap : allJPA) {
allSpecialities.add(new MedicalSpecialtyTO(cap.getId(), cap.getName(), cap.getDescription()));
}
return allSpecialities;
}
public Collection<PrimaryHealthCareCenterTO> listAllCAPs() {
return this.listPagedAllCAPs(0, 0);
public List<PrimaryHealthCareCenterTO> listAllCAPs() {
return this.listCAPsPaged(0, 0);
}
public Collection<PrimaryHealthCareCenterTO> listPagedAllCAPs(int pageNumber, int pageSize) {
Query query = entman.createQuery("from PrimaryHealthCareCenterJPA order by name");
public List<PrimaryHealthCareCenterTO> listCAPsPaged(int pageNumber, int pageSize) {
return this.listCAPsFiltered(null, pageNumber, pageSize);
}
public List<PrimaryHealthCareCenterTO> listCAPsFiltered(String searchTerm, int pageNumber, int pageSize) {
String strQuery = "SELECT phc from PrimaryHealthCareCenterJPA phc %s order by phc.name, phc.location";
String strFilter = "";
if (searchTerm == null)
searchTerm = "";
else
searchTerm = Utils.stripAccents(searchTerm).toLowerCase();
if (searchTerm.length() > 0) {
strFilter = "WHERE lower(phc.name) LIKE :searchTerm OR lower(phc.location) LIKE :searchTerm";
}
TypedQuery<PrimaryHealthCareCenterJPA> query = entman.createQuery(String.format(strQuery, strFilter), PrimaryHealthCareCenterJPA.class);
if (searchTerm.length() > 0)
query.setParameter("searchTerm", "%" + searchTerm + "%");
if (pageSize > 0) {
query.setFirstResult(pageNumber * pageSize);
query.setMaxResults(pageSize);
}
@SuppressWarnings("unchecked")
Collection<PrimaryHealthCareCenterJPA> allJPA = query.getResultList();
Collection<PrimaryHealthCareCenterTO> allCAPs = new ArrayList<PrimaryHealthCareCenterTO>();
List<PrimaryHealthCareCenterJPA> allJPA = query.getResultList();
List<PrimaryHealthCareCenterTO> allCAPs = new ArrayList<PrimaryHealthCareCenterTO>();
for (PrimaryHealthCareCenterJPA cap : allJPA) {
allCAPs.add(new PrimaryHealthCareCenterTO(cap.getName(), cap.getLocation()));
allCAPs.add(new PrimaryHealthCareCenterTO(cap.getId(), cap.getName(), cap.getLocation()));
}
return allCAPs;
}
public Collection<FamilyDoctorTO> listAllFamilyDoctors() {
return this.listAllFamilyDoctors(0, 0);
public List<FamilyDoctorTO> listAllFamilyDoctors() {
return this.listFamilyDoctorsPaged(0, 0);
}
public Collection<FamilyDoctorTO> listAllFamilyDoctors(int pageNumber, int pageSize) {
Query query = entman.createQuery("from FamilyDoctorJPA order by name, surname");
public List<FamilyDoctorTO> listFamilyDoctorsPaged(int pageNumber, int pageSize) {
return this.listFamilyDoctorsFiltered(null, pageNumber, pageSize);
}
public List<FamilyDoctorTO> listFamilyDoctorsFiltered(String searchTerm, int pageNumber, int pageSize) {
String strQuery = "SELECT fd FROM FamilyDoctorJPA fd %s order by fd.name, fd.surname";
String strFilter = "";
if (searchTerm == null)
searchTerm = "";
else
searchTerm = Utils.stripAccents(searchTerm).toLowerCase();
if (searchTerm.length() > 0) {
strFilter = "WHERE lower(fd.name) LIKE :searchTerm OR lower(fd.surname) LIKE :searchTerm";
}
TypedQuery<FamilyDoctorJPA> query = entman.createQuery(String.format(strQuery, strFilter), FamilyDoctorJPA.class);
if (searchTerm.length() > 0)
query.setParameter("searchTerm", "%" + searchTerm + "%");
if (pageSize > 0) {
query.setFirstResult(pageNumber * pageSize);
@@ -94,14 +149,14 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
}
@SuppressWarnings("unchecked")
Collection<FamilyDoctorJPA> allFDsJPA = query.getResultList();
Collection<FamilyDoctorTO> allFDTOs = new ArrayList<FamilyDoctorTO>();
List<FamilyDoctorJPA> allFDsJPA = query.getResultList();
List<FamilyDoctorTO> allFDTOs = new ArrayList<FamilyDoctorTO>();
for (FamilyDoctorJPA item : allFDsJPA) {
allFDTOs.add(new FamilyDoctorTO(item.getId(), item.getNif(), item.getName(), item.getSurname(), item.getPassword(), item.getEmail(), null));
}
return allFDTOs;
return allFDTOs;
}
public PatientTO retrievePatient(int patientId) throws Exception {
@@ -129,7 +184,7 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
PrimaryHealthCareCenterTO phc = null;
if (fd.getPrimaryHealthCareCenter() != null)
phc = new PrimaryHealthCareCenterTO(fd.getPrimaryHealthCareCenter().getName(), fd.getPrimaryHealthCareCenter().getLocation());
phc = new PrimaryHealthCareCenterTO(fd.getPrimaryHealthCareCenter().getId(), fd.getPrimaryHealthCareCenter().getName(), fd.getPrimaryHealthCareCenter().getLocation());
FamilyDoctorTO fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), phc);
return fdTO;
@@ -144,7 +199,7 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
MedicalSpecialtyTO ms = null;
if (sd.getMedicalSpecialty() != null)
ms = new MedicalSpecialtyTO(sd.getMedicalSpecialty().getName(), sd.getMedicalSpecialty().getDescription());
ms = new MedicalSpecialtyTO(sd.getMedicalSpecialty().getId(), sd.getMedicalSpecialty().getName(), sd.getMedicalSpecialty().getDescription());
SpecialistDoctorTO sdTO = new SpecialistDoctorTO(sd.getId(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(), ms);
return sdTO;

View File

@@ -1,6 +1,7 @@
package ejb.common;
import java.util.Collection;
import java.util.List;
import javax.ejb.Local;
@@ -18,18 +19,24 @@ import TO.SpecialistDoctorTO;
@Local
public interface CommonFacadeLocal {
public Collection<MedicalSpecialtyTO> listAllMedicalSpecialities();
public List<MedicalSpecialtyTO> listAllMedicalSpecialities();
public Collection<MedicalSpecialtyTO> listPagedMedicalSpecialities(int pageNumber, int pageSize);
public List<MedicalSpecialtyTO> listMedicalSpecialitiesPaged(int pageNumber, int pageSize);
public Collection<PrimaryHealthCareCenterTO> listAllCAPs();
public Collection<PrimaryHealthCareCenterTO> listPagedAllCAPs(int pageNumber, int pageSize);
public List<MedicalSpecialtyTO> listMedicalSpecialitiesFiltered(String searchTerm, int pageNumber, int pageSize);
public List<PrimaryHealthCareCenterTO> listAllCAPs();
public List<PrimaryHealthCareCenterTO> listCAPsPaged(int pageNumber, int pageSize);
public List<PrimaryHealthCareCenterTO> listCAPsFiltered(String searchTerm, int pageNumber, int pageSize);
public List<FamilyDoctorTO> listAllFamilyDoctors();
public List<FamilyDoctorTO> listFamilyDoctorsPaged(int pageNumber, int pageSize);
public List<FamilyDoctorTO> listFamilyDoctorsFiltered(String searchTerm, int pageNumber, int pageSize);
public Collection<FamilyDoctorTO> listAllFamilyDoctors();
public Collection<FamilyDoctorTO> listAllFamilyDoctors(int pageNumber, int pageSize);
public PatientTO retrievePatient(int patientId) throws Exception;
public FamilyDoctorTO retrieveFamilyDoctor(int ProfessionalNumberId) throws Exception;

View File

@@ -1,6 +1,7 @@
package ejb.common;
import java.util.Collection;
import java.util.List;
import javax.ejb.Remote;
@@ -18,18 +19,24 @@ import TO.SpecialistDoctorTO;
@Remote
public interface CommonFacadeRemote {
public Collection<MedicalSpecialtyTO> listAllMedicalSpecialities();
public List<MedicalSpecialtyTO> listAllMedicalSpecialities();
public Collection<MedicalSpecialtyTO> listPagedMedicalSpecialities(int pageNumber, int pageSize);
public List<MedicalSpecialtyTO> listMedicalSpecialitiesPaged(int pageNumber, int pageSize);
public Collection<PrimaryHealthCareCenterTO> listAllCAPs();
public Collection<PrimaryHealthCareCenterTO> listPagedAllCAPs(int pageNumber, int pageSize);
public List<MedicalSpecialtyTO> listMedicalSpecialitiesFiltered(String searchTerm, int pageNumber, int pageSize);
public List<PrimaryHealthCareCenterTO> listAllCAPs();
public List<PrimaryHealthCareCenterTO> listCAPsPaged(int pageNumber, int pageSize);
public List<PrimaryHealthCareCenterTO> listCAPsFiltered(String searchTerm, int pageNumber, int pageSize);
public List<FamilyDoctorTO> listAllFamilyDoctors();
public List<FamilyDoctorTO> listFamilyDoctorsPaged(int pageNumber, int pageSize);
public List<FamilyDoctorTO> listFamilyDoctorsFiltered(String searchTerm, int pageNumber, int pageSize);
public Collection<FamilyDoctorTO> listAllFamilyDoctors();
public Collection<FamilyDoctorTO> listAllFamilyDoctors(int pageNumber, int pageSize);
public PatientTO retrievePatient(int patientId) throws Exception;
public FamilyDoctorTO retrieveFamilyDoctor(int ProfessionalNumberId) throws Exception;

View File

@@ -67,7 +67,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
public SpecialistDoctorTO registerSpecialistDoctor(int id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO specialty)
throws Exception {
MedicalSpecialtyJPA ms = entman.find(MedicalSpecialtyJPA.class, specialty.getName());
MedicalSpecialtyJPA ms = entman.find(MedicalSpecialtyJPA.class, specialty.getId());
if (ms == null) {
throw new Exception("No se encuentra la especialidad médica con identificador: " + specialty.getName());
}
@@ -84,7 +84,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
public FamilyDoctorTO registerFamilyDoctor(int id, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterTO cap) throws Exception {
FamilyDoctorTO fdTO = null;
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, cap.getName());
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, cap.getId());
if (phcC == null) {
throw new Exception("No se encuentra el centro de atención primaria con identificador: " + cap.getName());
}
@@ -127,7 +127,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
throw new Exception("No se pueden actualizar los datos del médico de familia porque no se encuentra en la base de datos ningún registro con id: " + String.valueOf(id));
}
MedicalSpecialtyJPA ms = entman.find(MedicalSpecialtyJPA.class, specialty.getName());
MedicalSpecialtyJPA ms = entman.find(MedicalSpecialtyJPA.class, specialty.getId());
if (ms == null) {
throw new Exception("No se encuentra la especialidad médica con identificador: " + specialty.getName());
}
@@ -155,7 +155,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
throw new Exception("No se pueden actualizar los datos del médico de familia porque no se encuentra en la base de datos ningún registro con id: " + String.valueOf(id));
}
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, phcTO.getName());
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, phcTO.getId());
if (phcC == null) {
throw new Exception("No se encuentra el centro de atención primaria con identificador: " + phcTO.getName());
}
@@ -185,7 +185,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
throw new Exception("No se encuentra en la base de datos ningún médico de familia con id: " + String.valueOf(professionalId));
}
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, newCenter.getName());
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, newCenter.getId());
if (phcC == null) {
throw new Exception("No se encuentra el centro de atención primaria con identificador: " + newCenter.getName());
}

View File

@@ -4,6 +4,7 @@ import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
@@ -26,6 +27,7 @@ public class FamilyDoctorJPA implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(updatable = false)
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer id;
private String nif;

View File

@@ -2,7 +2,10 @@ package jpa;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@@ -18,6 +21,9 @@ public class MedicalSpecialtyJPA implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(updatable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String name;
private String description;
@@ -33,7 +39,14 @@ public class MedicalSpecialtyJPA implements Serializable {
this.description = description;
}
@Id
public Integer getId() {
return id;
}
public void setId(Integer value) {
this.id = value;
}
public String getName() {
return name;
}

View File

@@ -2,6 +2,7 @@ package jpa;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
@@ -22,7 +23,8 @@ public class PatientJPA implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(updatable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String nif;
private String name;
@@ -30,7 +32,7 @@ public class PatientJPA implements Serializable {
private String password;
private String email;
@ManyToOne
@JoinColumn (name="FamilyDoctorId")
@JoinColumn(name = "FamilyDoctorId")
private FamilyDoctorJPA familyDoctor;
/**
@@ -96,11 +98,12 @@ public class PatientJPA implements Serializable {
public void setEmail(String email) {
this.email = email;
}
public FamilyDoctorJPA getFamilyDoctor() {
return familyDoctor;
}
public void setFamilyDoctor(FamilyDoctorJPA familyDoc) {
public void setFamilyDoctor(FamilyDoctorJPA familyDoc) {
this.familyDoctor = familyDoc;
}
}

View File

@@ -2,7 +2,10 @@ package jpa;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@@ -18,6 +21,9 @@ public class PrimaryHealthCareCenterJPA implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(updatable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String name;
private String location;
@@ -33,6 +39,14 @@ public class PrimaryHealthCareCenterJPA implements Serializable {
this.location = location;
}
public Integer getId() {
return id;
}
public void setId(Integer value) {
this.id = value;
}
public String getName() {
return name;
}

View File

@@ -2,6 +2,7 @@ package jpa;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
@@ -22,7 +23,8 @@ public class SpecialistDoctorJPA implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(updatable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String nif;
private String name;
@@ -30,7 +32,7 @@ public class SpecialistDoctorJPA implements Serializable {
private String password;
private String email;
@ManyToOne
@JoinColumn(name = "MedicalSpecialtyId")
@JoinColumn(name = "MedicalSpecialtyId")
private MedicalSpecialtyJPA medicalSpecialty;
/**

View File

@@ -4,6 +4,7 @@ import java.io.Serializable;
import java.sql.Time;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
@@ -12,7 +13,6 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
/**
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
@@ -25,17 +25,19 @@ public class VisitJPA implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(updatable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private Date date;
private Time time;
private String observations;
private String result;
@ManyToOne
@JoinColumn (name="FamilyDoctorId")
private FamilyDoctorJPA familyDoctor;
@ManyToOne
@JoinColumn (name="PatientId")
private PatientJPA patient;
@ManyToOne
@JoinColumn(name = "FamilyDoctorId")
private FamilyDoctorJPA familyDoctor;
@ManyToOne
@JoinColumn(name = "PatientId")
private PatientJPA patient;
/**
* Class constructor methods
@@ -46,14 +48,14 @@ public class VisitJPA implements Serializable {
public VisitJPA(Integer id, Date date, Time time, String observations, String result) {
this.id = id;
this.date=date;
this.date = date;
this.time = time;
this.observations = observations;
this.result = result;
}
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Integer getId() {
return id;
}
@@ -85,21 +87,23 @@ public class VisitJPA implements Serializable {
public void setObservations(String observation) {
this.observations = observations;
}
/**
* Methods get/set persistent relationships
*/
public FamilyDoctorJPA getFamilyDoctor() {
return familyDoctor;
}
public void setFamilyDoctor(FamilyDoctorJPA familyDoc) {
public void setFamilyDoctor(FamilyDoctorJPA familyDoc) {
this.familyDoctor = familyDoc;
}
public PatientJPA getPatient() {
return patient;
}
public void setPatient (PatientJPA pat) {
this.patient=pat;
public void setPatient(PatientJPA pat) {
this.patient = pat;
}
}
}

View File

@@ -1,7 +1,7 @@
package managedbean.profile;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
@@ -11,6 +11,7 @@ import javax.inject.Named;
import TO.FamilyDoctorTO;
import TO.LoggedUserTO;
import TO.PatientTO;
import common.Constants;
import common.UserType;
import managedbean.common.ManagedBeanBase;
import managedbean.common.SessionUtils;
@@ -28,7 +29,8 @@ public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializ
private int id;
private FamilyDoctorTO currentFamilyDoctor;
private FamilyDoctorTO newFamilyDoctor;
private Collection<FamilyDoctorTO> familyDoctorList;
private List<FamilyDoctorTO> familyDoctorList;
private String lastUIQuery;
public ChangeFamilyDoctorMBean() {
@@ -38,6 +40,7 @@ public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializ
public void init() {
// Recuperamos el usuario logeado actual
LoggedUserTO usr = null;
this.lastUIQuery = "";
try {
usr = SessionUtils.getloggedOnUser();
@@ -48,7 +51,7 @@ public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializ
this.id = Integer.valueOf(usr.getId());
if (usr.getUserType() == UserType.PATIENT) {
this.familyDoctorList = this.getRemoteManagerCommon().listAllFamilyDoctors();
this.familyDoctorList = this.getRemoteManagerCommon().listFamilyDoctorsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
PatientTO pat = this.getRemoteManagerCommon().retrievePatient(this.id);
this.setCurrentFamilyDoctor(pat.getFamilyDoctor());
@@ -60,10 +63,19 @@ public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializ
}
public Collection<FamilyDoctorTO> getFamilyDoctorList() {
public List<FamilyDoctorTO> getFamilyDoctorList() {
return familyDoctorList;
}
public List<FamilyDoctorTO> completeFamilyDoctor(String query) {
if (query != null && query.equals(this.lastUIQuery) == false) {
this.lastUIQuery = query;
// Recuperamos las 200 primeras coincidencias
this.familyDoctorList = this.getRemoteManagerCommon().listFamilyDoctorsFiltered(query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
}
return this.familyDoctorList;
}
public int getId() {
return id;
}

View File

@@ -2,6 +2,7 @@ package managedbean.profile;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
@@ -11,6 +12,7 @@ import javax.inject.Named;
import TO.FamilyDoctorTO;
import TO.LoggedUserTO;
import TO.PrimaryHealthCareCenterTO;
import common.Constants;
import common.UserType;
import managedbean.common.ManagedBeanBase;
import managedbean.common.SessionUtils;
@@ -28,7 +30,8 @@ public class ChangePrimaryHealthCareCenterMBean extends ManagedBeanBase implemen
private int id;
private PrimaryHealthCareCenterTO currentCenter;
private PrimaryHealthCareCenterTO newCenter;
private Collection<PrimaryHealthCareCenterTO> primaryHealthCareCentersList;
private List<PrimaryHealthCareCenterTO> primaryHealthCareCentersList;
private String lastUIQuery;
public ChangePrimaryHealthCareCenterMBean() {
@@ -38,6 +41,8 @@ public class ChangePrimaryHealthCareCenterMBean extends ManagedBeanBase implemen
public void init() {
// Recuperamos el usuario logeado actual
LoggedUserTO usr = null;
this.lastUIQuery = "";
try {
usr = SessionUtils.getloggedOnUser();
@@ -48,7 +53,7 @@ public class ChangePrimaryHealthCareCenterMBean extends ManagedBeanBase implemen
this.id = Integer.valueOf(usr.getId());
if (usr.getUserType() == UserType.FAMILY_DOCTOR) {
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listAllCAPs();
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
FamilyDoctorTO fd = this.getRemoteManagerCommon().retrieveFamilyDoctor(this.id);
this.setCurrentCenter(fd.getPrimaryHealthCareCenter());
@@ -60,9 +65,18 @@ public class ChangePrimaryHealthCareCenterMBean extends ManagedBeanBase implemen
}
public Collection<PrimaryHealthCareCenterTO> getPhcList() {
public List<PrimaryHealthCareCenterTO> getPhcList() {
return primaryHealthCareCentersList;
}
public List<PrimaryHealthCareCenterTO> completePrimaryHealCareCenter(String query) {
if (query != null && query.equals(this.lastUIQuery) == false) {
this.lastUIQuery = query;
// Recuperamos las 200 primeras coincidencias
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsFiltered(query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
}
return this.primaryHealthCareCentersList;
}
public int getId() {
return id;

View File

@@ -19,6 +19,7 @@ import TO.MedicalSpecialtyTO;
import TO.PatientTO;
import TO.PrimaryHealthCareCenterTO;
import TO.SpecialistDoctorTO;
import common.Constants;
import common.UserType;
import managedbean.common.ManagedBeanBase;
import managedbean.common.ValidationUtils;
@@ -44,14 +45,16 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
private String password;
private String email;
private boolean registered;
private String lastUIQueryPH;
private String lastUIQueryMS;
// private HashMap<String, String> userTypes;
private List<UserType> userTypes;
private String userType;
private PrimaryHealthCareCenterTO primaryHealthCareCenter;
private MedicalSpecialtyTO medicalSpecialty;
private Collection<MedicalSpecialtyTO> medicalSpecialitiesList;
private Collection<PrimaryHealthCareCenterTO> primaryHealthCareCentersList;
private List<MedicalSpecialtyTO> medicalSpecialitiesList;
private List<PrimaryHealthCareCenterTO> primaryHealthCareCentersList;
public RegisterUserMBean() {
@@ -64,11 +67,13 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
this.userTypes.add(UserType.FAMILY_DOCTOR);
this.userTypes.add(UserType.SPECIALIST_DOCTOR);
this.registered = false;
this.lastUIQueryPH = "";
this.lastUIQueryMS = "";
this.userType = UserType.PATIENT.name();
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listAllMedicalSpecialities();
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listAllCAPs();
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
}
public List<UserType> getUserTypes() {
@@ -98,14 +103,32 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
}
}
public Collection<MedicalSpecialtyTO> getMedicalSpecialtiesList() {
public List<MedicalSpecialtyTO> getMedicalSpecialtiesList() {
return medicalSpecialitiesList;
}
public Collection<PrimaryHealthCareCenterTO> getPhcList() {
public List<PrimaryHealthCareCenterTO> getPhcList() {
return primaryHealthCareCentersList;
}
public List<PrimaryHealthCareCenterTO> completePrimaryHealCareCenter(String query) {
if (query != null && query.equals(this.lastUIQueryPH) == false) {
this.lastUIQueryPH = query;
// Recuperamos las 200 primeras coincidencias
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsFiltered(query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
}
return this.primaryHealthCareCentersList;
}
public List<MedicalSpecialtyTO> completeMedicalSpecialty(String query) {
if (query != null && query.equals(this.lastUIQueryMS) == false) {
this.lastUIQueryMS = query;
// Recuperamos las 200 primeras coincidencias
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesFiltered(query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
}
return this.medicalSpecialitiesList;
}
public boolean isPatient() {
return (UserType.valueOf(this.userType) == UserType.PATIENT);
}

View File

@@ -4,18 +4,11 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.view.ViewScoped;
import javax.inject.Named;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.print.attribute.standard.Severity;
import javax.resource.NotSupportedException;
import org.primefaces.PrimeFaces;
@@ -26,9 +19,9 @@ import TO.MedicalSpecialtyTO;
import TO.PatientTO;
import TO.PrimaryHealthCareCenterTO;
import TO.SpecialistDoctorTO;
import common.Constants;
import common.HashUtils;
import common.UserType;
import ejb.systemAdmin.SystemAdminFacadeRemote;
import managedbean.common.ManagedBeanBase;
import managedbean.common.SessionUtils;
import managedbean.common.ValidationUtils;
@@ -54,13 +47,18 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
private String oldPassword;
private String password;
private String email;
private String lastUIQueryPH;
private String lastUIQueryMS;
private String lastUIQueryFD;
private List<UserType> userTypes;
private String userType;
private PrimaryHealthCareCenterTO primaryHealthCareCenter;
private MedicalSpecialtyTO medicalSpecialty;
private Collection<MedicalSpecialtyTO> medicalSpecialitiesList;
private Collection<PrimaryHealthCareCenterTO> primaryHealthCareCentersList;
private List<MedicalSpecialtyTO> medicalSpecialitiesList;
private List<PrimaryHealthCareCenterTO> primaryHealthCareCentersList;
private FamilyDoctorTO familyDoctor;
private List<FamilyDoctorTO> familyDoctorList;
public UpdateProfileMBean() {
@@ -72,6 +70,8 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
this.userTypes.add(UserType.PATIENT);
this.userTypes.add(UserType.FAMILY_DOCTOR);
this.userTypes.add(UserType.SPECIALIST_DOCTOR);
this.lastUIQueryPH = "";
this.lastUIQueryMS = "";
// Recuperamos el usuario logeado actual
LoggedUserTO usr = null;
@@ -87,6 +87,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
switch (usr.getUserType()) {
case PATIENT:
this.familyDoctorList = this.getRemoteManagerCommon().listFamilyDoctorsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
PatientTO pat = this.getRemoteManagerCommon().retrievePatient(this.id);
this.name = pat.getName();
@@ -96,7 +97,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
this.currentPassword = pat.getPassword();
break;
case SPECIALIST_DOCTOR:
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listAllMedicalSpecialities();
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
SpecialistDoctorTO sd = this.getRemoteManagerCommon().retrieveSpecialistDoctor(this.id);
this.name = sd.getName();
@@ -107,7 +108,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
this.medicalSpecialty = sd.getMedicalSpecialty();
break;
case FAMILY_DOCTOR:
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listAllCAPs();
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
FamilyDoctorTO fd = this.getRemoteManagerCommon().retrieveFamilyDoctor(this.id);
this.name = fd.getName();
@@ -156,28 +157,59 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
}
}
public Collection<MedicalSpecialtyTO> getMedicalSpecialtiesList() {
public List<MedicalSpecialtyTO> getMedicalSpecialtiesList() {
return medicalSpecialitiesList;
}
public Collection<PrimaryHealthCareCenterTO> getPhcList() {
public List<PrimaryHealthCareCenterTO> getPhcList() {
return primaryHealthCareCentersList;
}
public boolean isPatient() {
public List<PrimaryHealthCareCenterTO> completePrimaryHealCareCenter(String query) {
if (query != null && query.equals(this.lastUIQueryPH) == false) {
this.lastUIQueryPH = query;
// Recuperamos las 200 primeras coincidencias
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsFiltered(query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
}
return this.primaryHealthCareCentersList;
}
public List<MedicalSpecialtyTO> completeMedicalSpecialty(String query) {
if (query != null && query.equals(this.lastUIQueryMS) == false) {
this.lastUIQueryMS = query;
// Recuperamos las 200 primeras coincidencias
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesFiltered(query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
}
return this.medicalSpecialitiesList;
}
public List<FamilyDoctorTO> getFamilyDoctorList() {
return familyDoctorList;
}
public List<FamilyDoctorTO> completeFamilyDoctor(String query) {
if (query != null && query.equals(this.lastUIQueryFD) == false) {
this.lastUIQueryFD = query;
// Recuperamos las 200 primeras coincidencias
this.familyDoctorList = this.getRemoteManagerCommon().listFamilyDoctorsFiltered(query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
}
return this.familyDoctorList;
}
public boolean isUserTypePatient() {
return (UserType.valueOf(this.userType) == UserType.PATIENT);
}
public boolean isFamilyDoctor() {
public boolean isUserTypeFamilyDoctor() {
return (UserType.valueOf(this.userType) == UserType.FAMILY_DOCTOR);
}
public boolean isSpecialistDoctor() {
public boolean isUserTypeSpecialistDoctor() {
return (UserType.valueOf(this.userType) == UserType.SPECIALIST_DOCTOR);
}
public boolean isDoctor() {
return (isFamilyDoctor() || isSpecialistDoctor());
public boolean isUserTypeDoctor() {
return (isUserTypeFamilyDoctor() || isUserTypeSpecialistDoctor());
}
public String getEmail() {
@@ -228,11 +260,11 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
int error = 0;
boolean changePassword = (this.oldPassword != null && this.oldPassword.equals("") == false) || (this.password != null && this.password.equals("") == false);
if (this.isFamilyDoctor() && this.primaryHealthCareCenter == null) {
if (this.isUserTypeFamilyDoctor() && this.primaryHealthCareCenter == null) {
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Centro de atención primaria no seleccionado", "Por favor, especifique un centro de atención primaria.");
error++;
}
if (this.isSpecialistDoctor() && this.medicalSpecialty == null) {
if (this.isUserTypeSpecialistDoctor() && this.medicalSpecialty == null) {
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Especialidad médica no seleccionada", "Por favor, especifique una especialidad médica.");
error++;
}
@@ -320,4 +352,12 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
this.oldPassword = oldPassword;
}
public FamilyDoctorTO getFamilyDoctor() {
return familyDoctor;
}
public void setFamilyDoctor(FamilyDoctorTO familyDoctor) {
this.familyDoctor = familyDoctor;
}
}