Implementación de registro de usuarios para pacientes, medicos de
familia y medicos especialistas. * Correcciones varias a clases JPA. * Correcciones en clases POJO. * Listas desplegables para selección de especialidaes y CAPs. * Validaciones varias. * Estilo de interfaz con flexUI de PrimeFaces.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.jboss.ide.eclipse.as.core.server.runtime.runtimeTarget/WildFly 14.0 Runtime"/>
|
||||
<classpathentry kind="lib" path="docroot/WEB-INF/lib/primefaces-7.0.jar"/>
|
||||
<classpathentry kind="lib" path="docroot/WEB-INF/lib/primefaces-7.0.jar" sourcepath="C:/Users/mark/.m2/repository/org/primefaces/primefaces/7.0/primefaces-7.0-sources.jar"/>
|
||||
<classpathentry kind="lib" path="docroot/WEB-INF/lib/omnifaces-3.4.1.jar" sourcepath="C:/Users/mark/.m2/repository/org/omnifaces/omnifaces/3.4.1/omnifaces-3.4.1-sources.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
|
||||
<f:facet name="footer">
|
||||
<p:commandButton value="Login" update="messages" icon="pi pi-user" action="#{loginView.login}" oncomplete="handleLoginRequest(xhr, status, args)" />
|
||||
<i class="pi pi-spin pi-spinner" style="font-size: 3em"></i>
|
||||
<i class="pi pi-spin pi-spinner hide" style="font-size: 3em"></i>
|
||||
</f:facet>
|
||||
</h:panelGrid>
|
||||
</p:dialog>
|
||||
|
||||
@@ -9,85 +9,143 @@
|
||||
<h:outputScript>
|
||||
function handleRequest(xhr, status, args) {
|
||||
if(args.specs) {
|
||||
PF('panCentros').hide();
|
||||
$('#panCentros').fadeOut();
|
||||
PF('panEspecialidad').show()
|
||||
$('#panEspecialidad').fadeIn();
|
||||
$('#panCentros').slideUp();
|
||||
$('#panEspecialidades').slideDown();
|
||||
}
|
||||
else if (args.caps) {
|
||||
PF('panEspecialidad').hide();
|
||||
$('#panEspecialidad').fadeOut();
|
||||
PF('panCentros').show()
|
||||
$('#panCentros').fadeIn();
|
||||
$('#panEspecialidades').slideUp();
|
||||
$('#panCentros').slideDown();
|
||||
} else {
|
||||
$('#panCentros').slideUp();
|
||||
$('#panEspecialidades').slideUp();
|
||||
}
|
||||
}
|
||||
</h:outputScript>
|
||||
<h:form>
|
||||
<h:form id="frmRegisterUser">
|
||||
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
|
||||
|
||||
<p:panel id="tipoUsuario" header="Especifique el tipo de usuario que desea registrarse">
|
||||
<h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">
|
||||
<p:selectOneButton id="selUsertype" value="#{registerUser.userType}" required="true" requiredMessage="Debe especificar un tipo de usuario">
|
||||
<f:selectItems value="#{registerUser.userTypes}" />
|
||||
<p:ajax listener="#{registerUser.onUserTypeChange}" update="medicalSpecialty" oncomplete="handleRequest(xhr, status, args)" />
|
||||
</p:selectOneButton>
|
||||
</h:panelGrid>
|
||||
<div class="ui-g ui-fluid">
|
||||
<div class="ui-g-2 ui-md-2">
|
||||
<p:outputLabel value="Tipo de usuario:" for="selUsertype" />
|
||||
</div>
|
||||
<div class="ui-g-6 ui-md-6">
|
||||
<p:selectOneButton id="selUsertype" value="#{registerUser.userType}" required="true" unselectable="false" requiredMessage="Debe especificar un tipo de usuario">
|
||||
<f:selectItems value="#{registerUser.userTypes}" var="item" itemLabel="#{item.userTypename}" itemValue="#{item.name}" />
|
||||
<p:ajax listener="#{registerUser.onUserTypeChange}" update="selMS,selPHC" oncomplete="handleRequest(xhr, status, args)" />
|
||||
</p:selectOneButton>
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4"></div>
|
||||
</div>
|
||||
</p:panel>
|
||||
<p:panel id="RegisterUser" header="Datos personales para el usuario">
|
||||
<div class="ui-fluid">
|
||||
<h:panelGrid columns="3" layout="grid" columnClasses="p-col-12 p-md-3 p-xl-2, p-col-12 p-md-9 p-xl-4, p-col-12 p-md-3 p-xl-2, p-col-12 p-md-9 p-xl-4"
|
||||
contentStyleClass="ui-fluid">
|
||||
<p:panel id="DatosPersonales" header="Especifique el tipo de usuario que desea registrarse">
|
||||
<div class="ui-g ui-fluid">
|
||||
<div class="ui-g-2 ui-md-2">
|
||||
<p:outputLabel value="NIF:" for="nif" />
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<p:inputText id="nif" value="#{registerUser.nif}" required="true" requiredMessage="Por favor, indque su NIF" />
|
||||
</div>
|
||||
<div class="ui-g-6 ui-md-6">
|
||||
<p:message for="nif" display="text" />
|
||||
</div>
|
||||
|
||||
<div class="ui-g-2 ui-md-2">
|
||||
<p:outputLabel value="Nombre:" for="name" />
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<p:inputText id="name" value="#{registerUser.name}" required="true" requiredMessage="Por favor, indique su nombre" />
|
||||
</div>
|
||||
<div class="ui-g-6 ui-md-6">
|
||||
<p:message for="name" />
|
||||
</div>
|
||||
|
||||
<div class="ui-g-2 ui-md-2">
|
||||
<p:outputLabel value="Apellidos:" for="surname" />
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<p:inputText id="surname" value="#{registerUser.surname}" required="true" requiredMessage="Por favor, indique sus apellidos" />
|
||||
</div>
|
||||
<div class="ui-g-6 ui-md-6">
|
||||
<p:message for="surname" />
|
||||
</div>
|
||||
|
||||
<p:outputLabel value="Especialidad médica:" for="medicalSpecialty" />
|
||||
<p:selectOneMenu id="medicalSpecialty" value="#{registerUser.medicalSpecialty}" style="width:350px">
|
||||
<f:selectItem itemLabel="Seleccione una especialidad médica..." itemValue="" noSelectionOption="true" />
|
||||
<f:selectItems value="#{registerUser.medicalSpecialties}" var="c.TO" itemDescription="#{c.description}" itemValue="#{c.name}" />
|
||||
</p:selectOneMenu>
|
||||
|
||||
|
||||
<p:message for="medicalSpecialty" />
|
||||
<p:outputLabel value="Centro:" for="primaryHealthCareCenter" />
|
||||
<p:selectOneMenu id="primaryHealthCareCenter" value="#{registerUser.medicalSpecialty}" style="width:350px">
|
||||
<f:selectItem itemLabel="Seleccione un centro de antención primario..." itemValue="" noSelectionOption="true" />
|
||||
<f:selectItems value="#{registerUser.medicalSpecialties}" var="c" itemDescription="#{c.description}" itemValue="#{c.name}" />
|
||||
</p:selectOneMenu>
|
||||
<p:message for="primaryHealthCareCenter" />
|
||||
|
||||
<div class="ui-g-2 ui-md-2">
|
||||
<p:outputLabel value="Correo electrónico:" for="email" />
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<p:inputText id="email" value="#{registerUser.email}" required="true" requiredMessage="Por favor, especifique su correo electrónico" />
|
||||
</div>
|
||||
<div class="ui-g-6 ui-md-6">
|
||||
<p:message for="email" />
|
||||
|
||||
</div>
|
||||
<div class="ui-g-2 ui-md-2">
|
||||
<p:outputLabel value="Contraseña" for="password" />
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<p:password id="password" value="#{registerUser.password}" match="passwordRepeat" required="true" requiredMessage="Por favor, especifique una contraseña" maxlength="50"
|
||||
feedback="true" promptLabel="Especifique una contraseña segura" weakLabel="La contraseña es débil" goodLabel="La contraseña es buena" strongLabel="La contraseña es segura"
|
||||
validatorMessage="La contraseña y su verificación deben ser iguales" />
|
||||
</div>
|
||||
<div class="ui-g-6 ui-md-6">
|
||||
<p:message for="password" />
|
||||
|
||||
</div>
|
||||
<div class="ui-g-2">
|
||||
<p:outputLabel value="Verificación de contraseña:" for="passwordRepeat" />
|
||||
</div>
|
||||
<div class="ui-g-4">
|
||||
<p:password id="passwordRepeat" value="#{registerUser.password}" required="true" requiredMessage="Por favor, escriba la verificación de su contraseña" maxlength="50" />
|
||||
</div>
|
||||
<div class="ui-g-6">
|
||||
<p:message for="passwordRepeat" />
|
||||
</div>
|
||||
|
||||
<div id="panCentros" class="ui-g-12 ui-g-nopad hide">
|
||||
<div class="ui-g-2 ui-md-2">
|
||||
<p:outputLabel value="Centro:" for="selPHC" />
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<p:selectOneMenu id="selPHC" value="#{registerUser.primaryHealthCareCenter}" converter="omnifaces.SelectItemsConverter" required="#{registerUser.familyDoctor}" requiredMessage="Por favor, selecciona un centro de antención primaria">
|
||||
<f:selectItem itemLabel="Seleccione un centro de antención primario..." itemValue="" noSelectionOption="true" />
|
||||
<f:selectItems value="#{registerUser.phcList}" var="phc" itemLabel="#{phc.location}" itemValue="#{phc}" />
|
||||
<p:column>#{phc.name}</p:column>
|
||||
<p:column>#{phc.location}</p:column>
|
||||
</p:selectOneMenu>
|
||||
</div>
|
||||
<div class="ui-g-6 ui-md-6">
|
||||
<p:message for="selPHC" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="panEspecialidades" class="ui-g-12 ui-g-nopad hide">
|
||||
<div class="ui-g-2 ui-md-2">
|
||||
<p:outputLabel value="Especialidad médica:" for="selMS" />
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<p:selectOneMenu id="selMS" value="#{registerUser.medicalSpecialty}" converter="omnifaces.SelectItemsConverter" required="#{registerUser.specialistDoctor}" requiredMessage="Por favor, seleccione una especialidad médica" >
|
||||
<f:selectItem itemLabel="Seleccione una especialidad médica..." itemValue="" noSelectionOption="true" />
|
||||
<f:selectItems value="#{registerUser.medicalSpecialtiesList}" var="ms" itemLabel="#{ms.description}" itemValue="#{ms}" />
|
||||
<p:column>#{ms.name}</p:column>
|
||||
<p:column>#{ms.description}</p:column>
|
||||
</p:selectOneMenu>
|
||||
</div>
|
||||
<div class="ui-g-6 ui-md-6">
|
||||
<p:message for="selMS" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</h:panelGrid>
|
||||
<h:panelGrid columns="3" layout="grid" columnClasses="p-col-12 p-md-3 p-xl-2, p-col-12 p-md-9 p-xl-4, p-col-12 p-md-3 p-xl-2, p-col-12 p-md-9 p-xl-4">
|
||||
<p:commandButton type="button" validateClient="true" value="Registrarse" update="mesgs" action="#{registerUser.addNewUser}" icon="pi pi-check" />
|
||||
<p:commandButton type="button" value="Volver" outcome="home" />
|
||||
|
||||
</h:panelGrid>
|
||||
|
||||
<div class="ui-g-12 ui-g-nopad">
|
||||
<div class="ui-g-4 ui-md-4"></div>
|
||||
<div class="ui-g-2 ui-md-2 ">
|
||||
<p:commandButton validateClient="true" value="Registrarse" update="mesgs" action="#{registerUser.addNewUser}" icon="pi pi-check" />
|
||||
</div>
|
||||
<div class="ui-g-2 ui-md-2">
|
||||
<p:commandButton type="button" value="Volver" outcome="home" icon="pi pi-home" />
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</p:panel>
|
||||
</h:form>
|
||||
</ui:define>
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
BODY{
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
.hide {
|
||||
display: none;
|
||||
}
|
||||
@@ -41,4 +41,10 @@ public class MedicalSpecialtyTO implements Serializable {
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s[name=%s]", getClass().getSimpleName(), getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,16 +15,16 @@ public class PrimaryHealthCareCenterTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String name;
|
||||
private String description;
|
||||
private String location;
|
||||
|
||||
|
||||
public PrimaryHealthCareCenterTO() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PrimaryHealthCareCenterTO(String name, String description) {
|
||||
public PrimaryHealthCareCenterTO(String name, String location) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -35,12 +35,30 @@ public class PrimaryHealthCareCenterTO implements Serializable {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
public void setLocation(String description) {
|
||||
this.location = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return (other instanceof PrimaryHealthCareCenterTO) && (name != null)
|
||||
? name.equals(((PrimaryHealthCareCenterTO) other).getName())
|
||||
: (other == this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (name != null)
|
||||
? (this.getClass().hashCode() + name.hashCode())
|
||||
: super.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s[name=%s]", getClass().getSimpleName(), getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,10 +67,10 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
||||
return sdTO;
|
||||
}
|
||||
|
||||
public FamilyDoctorTO registerFamilyDoctor1(Integer id, String nif, String name, String surname, String password, String email, String cap) {
|
||||
public FamilyDoctorTO registerFamilyDoctor1(Integer id, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterTO cap) {
|
||||
FamilyDoctorTO fdTO = null;
|
||||
|
||||
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, cap);
|
||||
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, cap.getName());
|
||||
|
||||
// TODO: Lanzar error si no encontramos el cap!!!!!
|
||||
if (phcC != null) {
|
||||
|
||||
@@ -20,15 +20,13 @@ public interface ProfileFacadeRemote {
|
||||
|
||||
public PatientTO registerPatient(Integer id, String nif, String name, String surname, String password, String email);
|
||||
|
||||
public SpecialistDoctorTO registerSpecialistDoctor(Integer id, String nif, String name, String surname, String password, String email,
|
||||
MedicalSpecialtyTO specialty);
|
||||
public SpecialistDoctorTO registerSpecialistDoctor(Integer id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO specialty);
|
||||
|
||||
public FamilyDoctorTO registerFamilyDoctor1(Integer id, String nif, String name, String surname, String password, String email, String cap);
|
||||
public FamilyDoctorTO registerFamilyDoctor1(Integer id, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterTO cap);
|
||||
|
||||
public PatientTO updatePacientData(Integer id, String nif, String name, String surname, String password, String email);
|
||||
|
||||
public SpecialistDoctorTO updateSpecialistDoctorData(Integer id, String nif, String name, String surname, String password, String email,
|
||||
MedicalSpecialtyTO specialty);
|
||||
public SpecialistDoctorTO updateSpecialistDoctorData(Integer id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO specialty);
|
||||
|
||||
public FamilyDoctorTO updateFamilyDoctorData(Integer id, String nif, String name, String surname, String password, String email, String cap);
|
||||
|
||||
|
||||
@@ -9,7 +9,9 @@ import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import TO.MedicalSpecialtyTO;
|
||||
import TO.PrimaryHealthCareCenterTO;
|
||||
import jpa.MedicalSpecialtyJPA;
|
||||
import jpa.PrimaryHealthCareCenterJPA;
|
||||
|
||||
/**
|
||||
* EJB Session Bean Class para la Practica 2, Ejercicio 1 (ISCSD) Implementa los
|
||||
@@ -59,4 +61,26 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
||||
return allSpecialities;
|
||||
}
|
||||
|
||||
public Collection<PrimaryHealthCareCenterTO> listAllCAPs() {
|
||||
return this.listPagedAllCAPs(0, 0);
|
||||
}
|
||||
|
||||
public Collection<PrimaryHealthCareCenterTO> listPagedAllCAPs(int pageNumber, int pageSize) {
|
||||
Query query = entman.createQuery("from PrimaryHealthCareCenterJPA order by name");
|
||||
|
||||
if (pageSize > 0) {
|
||||
query.setFirstResult(pageNumber * pageSize);
|
||||
query.setMaxResults(pageSize);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<PrimaryHealthCareCenterJPA> allJPA = query.getResultList();
|
||||
Collection<PrimaryHealthCareCenterTO> allCAPs = new ArrayList<PrimaryHealthCareCenterTO>();
|
||||
|
||||
for (PrimaryHealthCareCenterJPA cap : allJPA) {
|
||||
allCAPs.add(new PrimaryHealthCareCenterTO(cap.getName(), cap.getLocation()));
|
||||
}
|
||||
|
||||
return allCAPs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.Collection;
|
||||
import javax.ejb.Remote;
|
||||
|
||||
import TO.MedicalSpecialtyTO;
|
||||
import TO.PrimaryHealthCareCenterTO;
|
||||
|
||||
/**
|
||||
* Interfaz remota del EJB Definimos los métodos que estarán disponibles para
|
||||
@@ -19,4 +20,5 @@ public interface SystemAdminFacadeRemote {
|
||||
* Definimos la interfaz remota
|
||||
*/
|
||||
public Collection<MedicalSpecialtyTO> listAllMedicalSpecialities();
|
||||
public Collection<PrimaryHealthCareCenterTO> listAllCAPs();
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public class PrimaryHealthCareCenterJPA implements Serializable {
|
||||
|
||||
@Id
|
||||
private String name;
|
||||
private String description;
|
||||
private String location;
|
||||
|
||||
/**
|
||||
* Class constructor methods
|
||||
@@ -28,9 +28,9 @@ public class PrimaryHealthCareCenterJPA implements Serializable {
|
||||
super();
|
||||
}
|
||||
|
||||
public PrimaryHealthCareCenterJPA(String name, String description) {
|
||||
public PrimaryHealthCareCenterJPA(String name, String location) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -41,11 +41,11 @@ public class PrimaryHealthCareCenterJPA implements Serializable {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
public void setLocation(String description) {
|
||||
this.location = description;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class SpecialistDoctorJPA implements Serializable {
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "MedicalSpecialtyName")
|
||||
@JoinColumn(name = "MedicalSpecialtyId")
|
||||
public MedicalSpecialtyJPA getMedicalSpecialty() {
|
||||
return medicalSpecialty;
|
||||
}
|
||||
|
||||
@@ -15,4 +15,8 @@ public enum UserType {
|
||||
public String getUserTypename() {
|
||||
return userTypename;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,15 +3,16 @@ package managedbean.profile;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.view.ViewScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.resource.NotSupportedException;
|
||||
|
||||
import org.primefaces.PrimeFaces;
|
||||
@@ -26,14 +27,14 @@ import managedbean.common.UserType;
|
||||
import managedbean.common.ValidationUtils;
|
||||
|
||||
/**
|
||||
* ManagedBEan que gestiona la edición y actualización de una especialidad
|
||||
* médica.
|
||||
* ManagedBEan que gestiona el registro de usuarios: Usuarios de tipo "Paciente"
|
||||
* Usuarios de tipo "Médico de Familia" usuarios de tipo "Médico especialista"
|
||||
*
|
||||
* @author mark
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@Named("registerUser")
|
||||
@RequestScoped
|
||||
@ViewScoped
|
||||
public class RegisterUserMBean extends ProfileMBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -45,12 +46,13 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
||||
private String password;
|
||||
private String passwordRepeat;
|
||||
private String email;
|
||||
private HashMap<String, String> userTypes;
|
||||
// private HashMap<String, String> userTypes;
|
||||
private List<UserType> userTypes;
|
||||
private String userType;
|
||||
private String primaryHealthCareCenter;
|
||||
private String medicalSpecialty;
|
||||
private Collection<MedicalSpecialtyTO> medicalSpecialities;
|
||||
private Collection<PrimaryHealthCareCenterTO> healthcareCenters;
|
||||
private PrimaryHealthCareCenterTO primaryHealthCareCenter;
|
||||
private MedicalSpecialtyTO medicalSpecialty;
|
||||
private Collection<MedicalSpecialtyTO> medicalSpecialitiesList;
|
||||
private Collection<PrimaryHealthCareCenterTO> primaryHealthCareCentersList;
|
||||
|
||||
/**
|
||||
* Constructor. Inicializa la conexión con el EJB Remoto
|
||||
@@ -63,15 +65,27 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
this.userTypes = new HashMap<String, String>();
|
||||
this.userTypes.put(UserType.PATIENT.getUserTypename(), UserType.PATIENT.name());
|
||||
this.userTypes.put(UserType.FAMILY_DOCTOR.getUserTypename(), UserType.FAMILY_DOCTOR.name());
|
||||
this.userTypes.put(UserType.SPECIALIST_DOCTOR.getUserTypename(), UserType.SPECIALIST_DOCTOR.name());
|
||||
this.userType = UserType.PATIENT.getUserTypename();
|
||||
this.userTypes = new ArrayList<UserType>();
|
||||
this.userTypes.add(UserType.PATIENT);
|
||||
this.userTypes.add(UserType.FAMILY_DOCTOR);
|
||||
this.userTypes.add(UserType.SPECIALIST_DOCTOR);
|
||||
|
||||
this.userType = UserType.PATIENT.name();
|
||||
|
||||
Properties props = System.getProperties();
|
||||
Context ctx;
|
||||
try {
|
||||
ctx = new InitialContext(props);
|
||||
SystemAdminFacadeRemote rman = (SystemAdminFacadeRemote) ctx.lookup("java:app/MyHealth.jar/SystemAdminFacadeBean!ejb.systemAdmin.SystemAdminFacadeRemote");
|
||||
|
||||
this.medicalSpecialitiesList = rman.listAllMedicalSpecialities();
|
||||
this.primaryHealthCareCentersList = rman.listAllCAPs();
|
||||
} catch (NamingException e) {
|
||||
this.manageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public HashMap<String, String> getUserTypes() {
|
||||
public List<UserType> getUserTypes() {
|
||||
return userTypes;
|
||||
}
|
||||
|
||||
@@ -79,12 +93,6 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
||||
switch (UserType.valueOf(this.userType)) {
|
||||
case SPECIALIST_DOCTOR:
|
||||
try {
|
||||
Properties props = System.getProperties();
|
||||
Context ctx = new InitialContext(props);
|
||||
SystemAdminFacadeRemote rman = (SystemAdminFacadeRemote) ctx.lookup("java:app/MyHealth.jar/SystemAdminFacadeBean!ejb.systemAdmin.SystemAdminFacadeRemote");
|
||||
|
||||
this.medicalSpecialities = rman.listAllMedicalSpecialities();
|
||||
|
||||
PrimeFaces.current().ajax().addCallbackParam("specs", true);
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
@@ -92,11 +100,6 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
||||
break;
|
||||
case FAMILY_DOCTOR:
|
||||
try {
|
||||
// TODO: Load Primary Healthcare Centers from remote EJB
|
||||
this.healthcareCenters = new ArrayList<PrimaryHealthCareCenterTO>();
|
||||
this.healthcareCenters.add(new PrimaryHealthCareCenterTO("Prueba", "Descripción prueba"));
|
||||
this.healthcareCenters.add(new PrimaryHealthCareCenterTO("Centro 2", "Centro 2"));
|
||||
|
||||
PrimeFaces.current().ajax().addCallbackParam("caps", true);
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
@@ -104,12 +107,37 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
||||
break;
|
||||
case ADMINISTRADOR:
|
||||
case PATIENT:
|
||||
PrimeFaces.current().ajax().addCallbackParam("pats", true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<MedicalSpecialtyTO> getMedicalSpecialties() {
|
||||
return medicalSpecialities;
|
||||
public Collection<MedicalSpecialtyTO> getMedicalSpecialtiesList() {
|
||||
return medicalSpecialitiesList;
|
||||
}
|
||||
|
||||
// public void setMedicalSpecialtiesList(Collection<MedicalSpecialtyTO> list) {
|
||||
// medicalSpecialitiesList = list;
|
||||
// }
|
||||
|
||||
public Collection<PrimaryHealthCareCenterTO> getPhcList() {
|
||||
return primaryHealthCareCentersList;
|
||||
}
|
||||
|
||||
// public void setPhcList(Collection<PrimaryHealthCareCenterTO> list) {
|
||||
// primaryHealthCareCentersList = list;
|
||||
// }
|
||||
|
||||
public boolean isPatient() {
|
||||
return (UserType.valueOf(this.userType) == UserType.PATIENT);
|
||||
}
|
||||
|
||||
public boolean isFamilyDoctor() {
|
||||
return (UserType.valueOf(this.userType) == UserType.FAMILY_DOCTOR);
|
||||
}
|
||||
|
||||
public boolean isSpecialistDoctor() {
|
||||
return (UserType.valueOf(this.userType) == UserType.SPECIALIST_DOCTOR);
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
@@ -161,9 +189,22 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
||||
}
|
||||
|
||||
public void addNewUser() {
|
||||
int error = 0;
|
||||
|
||||
if (this.isFamilyDoctor() && 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) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Especialidad médica no seleccionada", "Por favor, especifique una especialidad médica.");
|
||||
error++;
|
||||
}
|
||||
if (ValidationUtils.isValid(nif) == false) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "El NIF indicado no es válido", "Por favor, especifique un NIF válido.");
|
||||
} else {
|
||||
error++;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
try {
|
||||
switch (UserType.valueOf(this.userType)) {
|
||||
case PATIENT:
|
||||
@@ -171,11 +212,11 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
||||
|
||||
break;
|
||||
case FAMILY_DOCTOR:
|
||||
FamilyDoctorTO fd = this.remoteManager.registerFamilyDoctor1(id, nif, name, surname, password, email, null);
|
||||
FamilyDoctorTO fd = this.remoteManager.registerFamilyDoctor1(id, nif, name, surname, password, email, this.primaryHealthCareCenter);
|
||||
|
||||
break;
|
||||
case SPECIALIST_DOCTOR:
|
||||
SpecialistDoctorTO sd = this.remoteManager.registerSpecialistDoctor(id, nif, name, surname, password, email, null);
|
||||
SpecialistDoctorTO sd = this.remoteManager.registerSpecialistDoctor(id, nif, name, surname, password, email, this.medicalSpecialty);
|
||||
|
||||
break;
|
||||
case ADMINISTRADOR:
|
||||
@@ -207,21 +248,21 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
||||
public void setUserType(String userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
public String getMedicalSpecialty() {
|
||||
|
||||
public MedicalSpecialtyTO getMedicalSpecialty() {
|
||||
return medicalSpecialty;
|
||||
}
|
||||
|
||||
public void setMedicalSpecialty(String medicalSpecialty) {
|
||||
public void setMedicalSpecialty(MedicalSpecialtyTO medicalSpecialty) {
|
||||
this.medicalSpecialty = medicalSpecialty;
|
||||
}
|
||||
|
||||
public String getPrimaryHealthCareCenter() {
|
||||
public PrimaryHealthCareCenterTO getPrimaryHealthCareCenter() {
|
||||
return primaryHealthCareCenter;
|
||||
}
|
||||
|
||||
public void setPrimaryHealthCareCenter(String primaryHealthCareCenter) {
|
||||
public void setPrimaryHealthCareCenter(PrimaryHealthCareCenterTO primaryHealthCareCenter) {
|
||||
this.primaryHealthCareCenter = primaryHealthCareCenter;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user