Esqueleto para consultar las visitas de un día.
This commit is contained in:
@@ -7,20 +7,15 @@ import java.util.Date;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* Transfer object (TO) MedicalSpecialtyTO Para el intercambio de datos entre la
|
||||
* capa de interfaz y la capa de negocio
|
||||
* Transfer object (TO) MedicalSpecialtyTO Para el intercambio de datos entre la capa de interfaz y la capa de negocio
|
||||
*
|
||||
* Además esta clase facilita la implementación futura de una Capa SOA (Se
|
||||
* define la anotación para la serialización de esta clase: @XmlRootElement(name
|
||||
* = "medicalspeciality")
|
||||
* Además esta clase facilita la implementación futura de una Capa SOA (Se define la anotación para la serialización de esta clase: @XmlRootElement(name = "medicalspeciality")
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@XmlRootElement(name = "Visit")
|
||||
public class VisitTO implements Serializable {
|
||||
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Integer id;
|
||||
@@ -34,42 +29,71 @@ public class VisitTO implements Serializable {
|
||||
public VisitTO() {
|
||||
super();
|
||||
}
|
||||
public VisitTO(Integer id, Date date, Time time, String observation, String result) {
|
||||
this.setId(id);
|
||||
this.date=date;
|
||||
//this.time
|
||||
|
||||
public VisitTO(Integer Id, Date date, Time time, String observations, String result, FamilyDoctorTO fd, PatientTO pat) {
|
||||
this.id = Id;
|
||||
this.date = date;
|
||||
this.time = time;
|
||||
this.observations = observations;
|
||||
this.result = result;
|
||||
this.familyDoctor = fd;
|
||||
this.patient = pat;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id=id;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public Date getDate() {
|
||||
return this.date;
|
||||
}
|
||||
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date=date;
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
|
||||
public Time getTime() {
|
||||
return this.time;
|
||||
}
|
||||
|
||||
|
||||
public void setTime(Time time) {
|
||||
this.time=time;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
|
||||
public String getObservations() {
|
||||
return this.observations;
|
||||
}
|
||||
|
||||
|
||||
public void setObservations(String observations) {
|
||||
this.observations=observations;
|
||||
this.observations = observations;
|
||||
}
|
||||
|
||||
public String getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(String result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public FamilyDoctorTO getFamilyDoctor() {
|
||||
return familyDoctor;
|
||||
}
|
||||
|
||||
public void setFamilyDoctor(FamilyDoctorTO familyDoctor) {
|
||||
this.familyDoctor = familyDoctor;
|
||||
}
|
||||
|
||||
public PatientTO getPatient() {
|
||||
return patient;
|
||||
}
|
||||
|
||||
public void setPatient(PatientTO patient) {
|
||||
this.patient = patient;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import TO.PatientTO;
|
||||
import TO.PrimaryHealthCareCenterTO;
|
||||
import TO.QuestionTO;
|
||||
import TO.SpecialistDoctorTO;
|
||||
import TO.VisitTO;
|
||||
import common.Utils;
|
||||
import jpa.FamilyDoctorJPA;
|
||||
import jpa.MedicalSpecialtyJPA;
|
||||
@@ -21,6 +22,7 @@ import jpa.PatientJPA;
|
||||
import jpa.PrimaryHealthCareCenterJPA;
|
||||
import jpa.QuestionJPA;
|
||||
import jpa.SpecialistDoctorJPA;
|
||||
import jpa.VisitJPA;
|
||||
|
||||
/***
|
||||
*
|
||||
@@ -479,4 +481,22 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
return qsTO;
|
||||
}
|
||||
|
||||
public VisitTO getPOJOforVisitJPA(VisitJPA qs, int nestedProps) {
|
||||
VisitTO qsTO = null;
|
||||
|
||||
if (qs != null) {
|
||||
FamilyDoctorJPA fd = null;
|
||||
PatientJPA pat = null;
|
||||
if (nestedProps > 0) {
|
||||
fd = qs.getFamilyDoctor();
|
||||
pat = qs.getPatient();
|
||||
}
|
||||
|
||||
nestedProps--;
|
||||
qsTO = new VisitTO(qs.getId(), qs.getDate(), qs.getTime(), qs.getObservations(), qs.getResult(), this.getPOJOforFamilyDoctorJPA(fd, nestedProps),
|
||||
this.getPOJOforPatientJPA(pat, nestedProps));
|
||||
}
|
||||
|
||||
return qsTO;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,14 @@ import TO.PatientTO;
|
||||
import TO.PrimaryHealthCareCenterTO;
|
||||
import TO.QuestionTO;
|
||||
import TO.SpecialistDoctorTO;
|
||||
import TO.VisitTO;
|
||||
import jpa.FamilyDoctorJPA;
|
||||
import jpa.MedicalSpecialtyJPA;
|
||||
import jpa.PatientJPA;
|
||||
import jpa.PrimaryHealthCareCenterJPA;
|
||||
import jpa.QuestionJPA;
|
||||
import jpa.SpecialistDoctorJPA;
|
||||
import jpa.VisitJPA;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -52,13 +54,13 @@ public interface CommonFacadeLocal {
|
||||
public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId);
|
||||
|
||||
public FamilyDoctorTO findFamilyDoctorByCode(String code);
|
||||
|
||||
|
||||
public FamilyDoctorTO findFamilyDoctorByNif(String searchValue);
|
||||
|
||||
public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId);
|
||||
|
||||
public SpecialistDoctorTO findSpecialistDoctorByCode(String code);
|
||||
|
||||
|
||||
public SpecialistDoctorTO findSpecialistDoctorByNif(String searchValue);
|
||||
|
||||
public MedicalSpecialtyTO getPOJOforMedicalSpecialtyJPA(MedicalSpecialtyJPA ms);
|
||||
@@ -72,4 +74,6 @@ public interface CommonFacadeLocal {
|
||||
public PatientTO getPOJOforPatientJPA(PatientJPA pat, int nestedProps);
|
||||
|
||||
public QuestionTO getPOJOforQuestionJPA(QuestionJPA qs, int nestedProps);
|
||||
|
||||
public VisitTO getPOJOforVisitJPA(VisitJPA qs, int nestedProps);
|
||||
}
|
||||
|
||||
@@ -1,28 +1,63 @@
|
||||
package ejb.visit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import TO.VisitTO;
|
||||
import common.QuestionStatus;
|
||||
import ejb.common.CommonFacadeLocal;
|
||||
import jpa.QuestionJPA;
|
||||
import jpa.VisitJPA;
|
||||
|
||||
/**
|
||||
* EJB Session Bean Class para la Practica 2, Ejercicio 1 (ISCSD) Implementa los
|
||||
* métodos de la capa de negocio que implementan la logica de negocio y la
|
||||
* interacción con la capa de persistencia.
|
||||
* EJB Session Bean Class para la Practica 2, Ejercicio 1 (ISCSD) Implementa los métodos de la capa de negocio que implementan la logica de negocio y la interacción con la capa de
|
||||
* persistencia.
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@Stateless
|
||||
public class VisitFacadeBean implements VisitFacadeRemote {
|
||||
|
||||
// Persistence Unit Context
|
||||
@PersistenceContext(unitName = "MyHealth")
|
||||
private EntityManager entman;
|
||||
EntityManager entman;
|
||||
|
||||
public void ejbMethod(String parameter)
|
||||
{
|
||||
|
||||
@EJB
|
||||
CommonFacadeLocal commonServices;
|
||||
|
||||
public Long getScheduledVisitsCount(int familyDoctorId, Date date) {
|
||||
TypedQuery<Long> query = entman.createQuery("SELECT count(1) from VisitJPA v where v.date=:date and v.familyDoctor.id=:docId", Long.class);
|
||||
query.setParameter("date", date);
|
||||
query.setParameter("docId", familyDoctorId);
|
||||
|
||||
return query.getSingleResult();
|
||||
}
|
||||
|
||||
public List<VisitTO> listAllScheduledVisitsPaged(int familyDoctorId, Date date, int pageNumber, int pageSize) {
|
||||
TypedQuery<VisitJPA> query = entman.createQuery("SELECT v from VisitJPA v where v.date=:date and v.familyDoctor.id=:docId order by v.date, v.time", VisitJPA.class);
|
||||
query.setParameter("date", date);
|
||||
query.setParameter("docId", familyDoctorId);
|
||||
|
||||
if (pageSize > 0) {
|
||||
query.setFirstResult(pageNumber * pageSize);
|
||||
query.setMaxResults(pageSize);
|
||||
}
|
||||
|
||||
List<VisitJPA> allJPA = query.getResultList();
|
||||
List<VisitTO> listTO = new ArrayList<VisitTO>();
|
||||
|
||||
for (VisitJPA item : allJPA) {
|
||||
listTO.add(commonServices.getPOJOforVisitJPA(item, 1));
|
||||
}
|
||||
|
||||
return listTO;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package ejb.visit;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Remote;
|
||||
|
||||
import TO.VisitTO;
|
||||
|
||||
/**
|
||||
* Interfaz remota del EJB Definimos los métodos que estarán disponibles para
|
||||
* los clientes del EJB
|
||||
* Interfaz remota del EJB Definimos los métodos que estarán disponibles para los clientes del EJB
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
@@ -14,5 +18,8 @@ public interface VisitFacadeRemote {
|
||||
/**
|
||||
* Definimos la interfaz remota
|
||||
*/
|
||||
public void ejbMethod(String parameter);
|
||||
|
||||
public Long getScheduledVisitsCount(int familyDoctorId, Date date);
|
||||
|
||||
public List<VisitTO> listAllScheduledVisitsPaged(int familyDoctorId, Date date, int pageNumber, int pageSize);
|
||||
}
|
||||
@@ -32,9 +32,11 @@ public class VisitJPA implements Serializable {
|
||||
private Time time;
|
||||
private String observations;
|
||||
private String result;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "FamilyDoctorId")
|
||||
private FamilyDoctorJPA familyDoctor;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "PatientId")
|
||||
private PatientJPA patient;
|
||||
@@ -46,16 +48,16 @@ public class VisitJPA implements Serializable {
|
||||
super();
|
||||
}
|
||||
|
||||
public VisitJPA(Integer id, Date date, Time time, String observations, String result) {
|
||||
public VisitJPA(Integer id, Date date, Time time, String observations, String result, PatientJPA patient, FamilyDoctorJPA familydoctor) {
|
||||
this.id = id;
|
||||
this.date = date;
|
||||
this.time = time;
|
||||
this.observations = observations;
|
||||
this.result = result;
|
||||
this.patient = patient;
|
||||
this.familyDoctor = familydoctor;
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -84,8 +86,8 @@ public class VisitJPA implements Serializable {
|
||||
return observations;
|
||||
}
|
||||
|
||||
public void setObservations(String observation) {
|
||||
this.observations = observations;
|
||||
public void setObservations(String value) {
|
||||
this.observations = value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,4 +108,12 @@ public class VisitJPA implements Serializable {
|
||||
public void setPatient(PatientJPA pat) {
|
||||
this.patient = pat;
|
||||
}
|
||||
|
||||
public String getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(String value) {
|
||||
this.result = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public class AuthorizationFilter implements Filter {
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/visit/VisitAddResult") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/visit/VisitViewSchedules") > 0)
|
||||
if (reqURI.indexOf("/visit/VisitList") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/medicaltest/MedicalTests") > 0)
|
||||
authorized = true;
|
||||
|
||||
@@ -64,7 +64,7 @@ public class MenuMBean implements Serializable {
|
||||
if (tipoUsuario == UserType.FAMILY_DOCTOR)
|
||||
subMenu.addElement(createMenuItem("Añadir resultado", "fa fa-align-left", "/visit/VisitView", null));
|
||||
if (tipoUsuario == UserType.FAMILY_DOCTOR)
|
||||
subMenu.addElement(createMenuItem("Ver agenda del día", "fa fa-repeat", "/visit/VisitView", null));
|
||||
subMenu.addElement(createMenuItem("Ver agenda del día", "fa fa-repeat", "/visit/VisitList", null));
|
||||
|
||||
model.addElement(subMenu);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user