Metodos para busqueda de pacientes, médicos de familia y medicos
especialistas por NIF.
This commit is contained in:
@@ -161,114 +161,153 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
|
||||
public MedicalSpecialtyTO getPOJOforMedicalSpecialtyJPA(MedicalSpecialtyJPA ms) {
|
||||
MedicalSpecialtyTO msTO = null;
|
||||
|
||||
|
||||
if (ms != null) {
|
||||
msTO = new MedicalSpecialtyTO(ms.getId(), ms.getName(), ms.getDescription());
|
||||
}
|
||||
|
||||
|
||||
return msTO;
|
||||
}
|
||||
|
||||
public PrimaryHealthCareCenterTO getPOJOforPrimaryHealthCareCenterJPA(PrimaryHealthCareCenterJPA phc) {
|
||||
PrimaryHealthCareCenterTO phcTO = null;
|
||||
|
||||
|
||||
if (phc != null) {
|
||||
phcTO = new PrimaryHealthCareCenterTO(phc.getId(), phc.getName(), phc.getLocation());
|
||||
}
|
||||
|
||||
|
||||
return phcTO;
|
||||
}
|
||||
|
||||
public SpecialistDoctorTO getPOJOforSpecialistDoctorJPA(SpecialistDoctorJPA sd, int nestedProps) {
|
||||
SpecialistDoctorTO sdTO = null;
|
||||
|
||||
|
||||
if (sd != null) {
|
||||
MedicalSpecialtyJPA ms = null;
|
||||
if (nestedProps > 0)
|
||||
ms = sd.getMedicalSpecialty();
|
||||
|
||||
nestedProps--;
|
||||
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getProfessionalNumber(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(), this.getPOJOforMedicalSpecialtyJPA(ms));
|
||||
|
||||
nestedProps--;
|
||||
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getProfessionalNumber(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(),
|
||||
this.getPOJOforMedicalSpecialtyJPA(ms));
|
||||
}
|
||||
|
||||
|
||||
return sdTO;
|
||||
}
|
||||
|
||||
|
||||
public FamilyDoctorTO getPOJOforFamilyDoctorJPA(FamilyDoctorJPA fd, int nestedProps) {
|
||||
FamilyDoctorTO fdTO = null;
|
||||
|
||||
|
||||
if (fd != null) {
|
||||
PrimaryHealthCareCenterJPA phc = null;
|
||||
if (nestedProps > 0)
|
||||
phc = fd.getPrimaryHealthCareCenter();
|
||||
|
||||
|
||||
nestedProps--;
|
||||
fdTO = new FamilyDoctorTO(fd.getId(), fd.getProfessionalNumber(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), this.getPOJOforPrimaryHealthCareCenterJPA(phc));
|
||||
fdTO = new FamilyDoctorTO(fd.getId(), fd.getProfessionalNumber(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(),
|
||||
this.getPOJOforPrimaryHealthCareCenterJPA(phc));
|
||||
}
|
||||
|
||||
|
||||
return fdTO;
|
||||
}
|
||||
|
||||
|
||||
public PatientTO getPOJOforPatientJPA(PatientJPA pat, int nestedProps) {
|
||||
PatientTO paTO = null;
|
||||
|
||||
|
||||
if (pat != null) {
|
||||
FamilyDoctorJPA fd = null;
|
||||
if (nestedProps > 0)
|
||||
fd = pat.getFamilyDoctor();
|
||||
|
||||
|
||||
nestedProps--;
|
||||
paTO = new PatientTO(pat.getId(), pat.getPersonalIdentificationCode(), pat.getNif(), pat.getName(), pat.getSurname(), pat.getPassword(), pat.getEmail(), this.getPOJOforFamilyDoctorJPA(fd, nestedProps));
|
||||
paTO = new PatientTO(pat.getId(), pat.getPersonalIdentificationCode(), pat.getNif(), pat.getName(), pat.getSurname(), pat.getPassword(), pat.getEmail(),
|
||||
this.getPOJOforFamilyDoctorJPA(fd, nestedProps));
|
||||
}
|
||||
|
||||
|
||||
return paTO;
|
||||
}
|
||||
|
||||
|
||||
public PatientTO findPatientById(int patientId) {
|
||||
// Recuperamos propiedades anidadas 1 nivel!
|
||||
return this.getPOJOforPatientJPA(entman.find(PatientJPA.class, patientId), 1);
|
||||
}
|
||||
|
||||
|
||||
public PatientJPA findPatientByCode(String code) {
|
||||
public PatientTO findPatientByCode(String code) {
|
||||
TypedQuery<PatientJPA> query = entman.createQuery("from PatientJPA pat where pat.personalIdentificationCode=:code", PatientJPA.class);
|
||||
|
||||
query.setMaxResults(1);
|
||||
query.setParameter("code", code);
|
||||
|
||||
|
||||
List<PatientJPA> results = query.getResultList();
|
||||
if (results.size() > 0)
|
||||
return results.get(0);
|
||||
return this.getPOJOforPatientJPA(results.get(0), 1);
|
||||
else
|
||||
return null; }
|
||||
return null;
|
||||
}
|
||||
|
||||
public PatientTO findPatientByNif(String searchValue) {
|
||||
TypedQuery<PatientJPA> query = entman.createQuery("from PatientJPA pat where pat.nif=:nif", PatientJPA.class);
|
||||
query.setMaxResults(1);
|
||||
query.setParameter("nif", searchValue);
|
||||
|
||||
List<PatientJPA> results = query.getResultList();
|
||||
if (results.size() > 0)
|
||||
return this.getPOJOforPatientJPA(results.get(0), 1);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId) {
|
||||
return this.getPOJOforFamilyDoctorJPA(entman.find(FamilyDoctorJPA.class, ProfessionalNumberId), 1);
|
||||
}
|
||||
|
||||
public FamilyDoctorJPA findFamilyDoctorByCode(String code) {
|
||||
public FamilyDoctorTO findFamilyDoctorByCode(String code) {
|
||||
TypedQuery<FamilyDoctorJPA> query = entman.createQuery("from FamilyDoctorJPA d where d.professionalNumber=:code", FamilyDoctorJPA.class);
|
||||
|
||||
|
||||
query.setParameter("code", code);
|
||||
|
||||
|
||||
List<FamilyDoctorJPA> results = query.getResultList();
|
||||
if (results.size() > 0)
|
||||
return results.get(0);
|
||||
return this.getPOJOforFamilyDoctorJPA(results.get(0), 1);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public FamilyDoctorTO findFamilyDoctorByNif(String searchValue) {
|
||||
TypedQuery<FamilyDoctorJPA> query = entman.createQuery("from FamilyDoctorJPA d where d.nif=:nif", FamilyDoctorJPA.class);
|
||||
query.setMaxResults(1);
|
||||
query.setParameter("nif", searchValue);
|
||||
|
||||
List<FamilyDoctorJPA> results = query.getResultList();
|
||||
if (results.size() > 0)
|
||||
return this.getPOJOforFamilyDoctorJPA(results.get(0), 1);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId) {
|
||||
return this.getPOJOforSpecialistDoctorJPA(entman.find(SpecialistDoctorJPA.class, ProfessionalNumberId), 1);
|
||||
}
|
||||
|
||||
public SpecialistDoctorJPA findSpecialistDoctorByCode(String code) {
|
||||
public SpecialistDoctorTO findSpecialistDoctorByCode(String code) {
|
||||
TypedQuery<SpecialistDoctorJPA> query = entman.createQuery("from SpecialistDoctorJPA d where d.professionalNumber=:code", SpecialistDoctorJPA.class);
|
||||
|
||||
|
||||
query.setParameter("code", code);
|
||||
|
||||
|
||||
List<SpecialistDoctorJPA> results = query.getResultList();
|
||||
if (results.size() > 0)
|
||||
return results.get(0);
|
||||
return this.getPOJOforSpecialistDoctorJPA(results.get(0), 1);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public SpecialistDoctorTO findSpecialistDoctorByNif(String searchValue) {
|
||||
TypedQuery<SpecialistDoctorJPA> query = entman.createQuery("from SpecialistDoctorJPA d where d.nif=:nif", SpecialistDoctorJPA.class);
|
||||
query.setMaxResults(1);
|
||||
query.setParameter("nif", searchValue);
|
||||
|
||||
List<SpecialistDoctorJPA> results = query.getResultList();
|
||||
if (results.size() > 0)
|
||||
return this.getPOJOforSpecialistDoctorJPA(results.get(0), 1);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -44,15 +44,21 @@ public interface CommonFacadeLocal {
|
||||
|
||||
public PatientTO findPatientById(int patientId);
|
||||
|
||||
public PatientJPA findPatientByCode(String code);
|
||||
public PatientTO findPatientByCode(String code);
|
||||
|
||||
public PatientTO findPatientByNif(String searchValue);
|
||||
|
||||
public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId);
|
||||
|
||||
public FamilyDoctorJPA findFamilyDoctorByCode(String code);
|
||||
public FamilyDoctorTO findFamilyDoctorByCode(String code);
|
||||
|
||||
public FamilyDoctorTO findFamilyDoctorByNif(String searchValue);
|
||||
|
||||
public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId);
|
||||
|
||||
public SpecialistDoctorJPA findSpecialistDoctorByCode(String code);
|
||||
public SpecialistDoctorTO findSpecialistDoctorByCode(String code);
|
||||
|
||||
public SpecialistDoctorTO findSpecialistDoctorByNif(String searchValue);
|
||||
|
||||
public MedicalSpecialtyTO getPOJOforMedicalSpecialtyJPA(MedicalSpecialtyJPA ms);
|
||||
|
||||
|
||||
@@ -42,14 +42,20 @@ public interface CommonFacadeRemote {
|
||||
|
||||
public PatientTO findPatientById(int patientId);
|
||||
|
||||
public PatientJPA findPatientByCode(String code);
|
||||
public PatientTO findPatientByCode(String code);
|
||||
|
||||
public PatientTO findPatientByNif(String searchValue);
|
||||
|
||||
public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId);
|
||||
|
||||
public FamilyDoctorJPA findFamilyDoctorByCode(String code);
|
||||
public FamilyDoctorTO findFamilyDoctorByCode(String code);
|
||||
|
||||
public FamilyDoctorTO findFamilyDoctorByNif(String searchValue);
|
||||
|
||||
public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId);
|
||||
|
||||
public SpecialistDoctorJPA findSpecialistDoctorByCode(String code);
|
||||
public SpecialistDoctorTO findSpecialistDoctorByCode(String code);
|
||||
|
||||
public SpecialistDoctorTO findSpecialistDoctorByNif(String searchValue);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user