diff --git a/1.sources/MyHealth/docroot/visit/UpdateVisit.xhtml b/1.sources/MyHealth/docroot/visit/UpdateVisit.xhtml
new file mode 100644
index 0000000..5924cab
--- /dev/null
+++ b/1.sources/MyHealth/docroot/visit/UpdateVisit.xhtml
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/1.sources/MyHealth/src/managedbean/visit/UpdateVisitMBean.java b/1.sources/MyHealth/src/managedbean/visit/UpdateVisitMBean.java
new file mode 100644
index 0000000..ae3281e
--- /dev/null
+++ b/1.sources/MyHealth/src/managedbean/visit/UpdateVisitMBean.java
@@ -0,0 +1,184 @@
+package managedbean.visit;
+
+import java.io.Serializable;
+import java.sql.Time;
+import java.time.LocalTime;
+import java.util.Date;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.RequestScoped;
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.faces.view.ViewScoped;
+import javax.inject.Named;
+
+import TO.FamilyDoctorTO;
+import TO.PatientTO;
+import TO.VisitTO;
+import common.UserType;
+import managedbean.common.ManagedBeanBase;
+import managedbean.common.SessionUtils;
+
+@Named("UpdateVisit")
+@ViewScoped
+public class UpdateVisitMBean extends ManagedBeanBase implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private Integer id;
+ private Date date;
+ private Date time;
+ private String observations;
+ private String result;
+ private PatientTO patient;
+ private FamilyDoctorTO familyDoctor;
+ private boolean onlyResult;
+ private String fromPage;
+
+ public UpdateVisitMBean() {
+ }
+
+ @PostConstruct
+ public void init() {
+ FacesContext context = FacesContext.getCurrentInstance();
+ Map requestParams = context.getExternalContext().getRequestParameterMap();
+ VisitTO vi = null;
+
+ try {
+ this.fromPage = requestParams.get("fromPage");
+
+ // Parámetro con el "id" de la visita.
+ int parId = Integer.valueOf(requestParams.get("id"));
+
+ vi = this.getRemoteManagerVisit().getVisit(parId);
+ } catch (Exception e) {
+ this.manageException(e);
+ }
+
+ if (vi != null) {
+ this.id = vi.getId();
+ this.date = vi.getDate();
+ this.time = vi.getTime();
+ this.observations = vi.getObservations();
+ this.result = vi.getResult();
+ this.patient = vi.getPatient();
+ this.familyDoctor = vi.getFamilyDoctor();
+ } else {
+ this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Identificador de visita no válido", "No se ha podido recuperar el identificador de visita especificado. Por favor, vuelva a intentarlo seleccionando de nuevo la visita.");
+ }
+
+ // Si el usuario es un paciente listamos las visitas de ese paciente, si es admnistrador listamos todas.
+ switch (SessionUtils.getUserType())
+ {
+ case ADMINISTRATOR:
+ case PATIENT:
+ // Administrador y paciente pueden actualizar cualquier dato de la visita (excepto esl resultado)
+ this.onlyResult = false;
+ break;
+ case FAMILY_DOCTOR:
+ // El médico de familia solo puede actualizar el resultado.
+ this.onlyResult = true;
+ break;
+ case SPECIALIST_DOCTOR:
+ this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Acesso denegado", "Su perfil de usuario no está autorizado acceder a esta página.");
+ return;
+ }
+ }
+
+ public void saveData() {
+ // Si el usuario es un paciente listamos las visitas de ese paciente, si es admnistrador listamos todas.
+ switch (SessionUtils.getUserType())
+ {
+ case ADMINISTRATOR:
+ case PATIENT:
+ // Administrador y paciente pueden actualizar la fecha y hora de la visita (excepto esl resultado)
+ // TODO: Implementar método en EJB
+ //this.getRemoteManagerVisit().updateVisit(this.id, this.date, this.time);
+ this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Visita actualizada", "La fecha y hora de la visita se ha actualizado correctamente.");
+ break;
+ case FAMILY_DOCTOR:
+ // El médico de familia solo puede actualizar el resultado.
+ //TODO: implementar método EJB para actualizar el resultado.
+ //this.getRemoteManagerVisit().addResultToVisit(this.id, this.result);
+ this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Resultado actualizado", "El resultado de la visita se ha actualizado correctamente.");
+ break;
+ case SPECIALIST_DOCTOR:
+ this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Acesso denegado", "Su perfil de usuario no está autorizado acceder a esta página.");
+ return;
+ }
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ public Date getTime() {
+ return time;
+ }
+
+ public void setTime(Date time) {
+ this.time = time;
+ }
+
+ public String getObservations() {
+ return observations;
+ }
+
+ public void setObservations(String observations) {
+ this.observations = observations;
+ }
+
+ public String getResult() {
+ return result;
+ }
+
+ public void setResult(String result) {
+ this.result = result;
+ }
+
+ public PatientTO getPatient() {
+ return patient;
+ }
+
+ public void setPatient(PatientTO patient) {
+ this.patient = patient;
+ }
+
+ public FamilyDoctorTO getFamilyDoctor() {
+ return familyDoctor;
+ }
+
+ public void setFamilyDoctor(FamilyDoctorTO familyDoctor) {
+ this.familyDoctor = familyDoctor;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public boolean isOnlyResult() {
+ return onlyResult;
+ }
+
+ public void setOnlyResult(boolean onlyResult) {
+ this.onlyResult = onlyResult;
+ }
+
+ public String getFromPage() {
+ return fromPage;
+ }
+
+ public void setFromPage(String fromPage) {
+ this.fromPage = fromPage;
+ }
+
+}