Metodos para busqueda de pacientes, médicos de familia y medicos

especialistas por NIF.
This commit is contained in:
Marcos Garcia Nuñez
2019-12-15 19:31:41 +01:00
parent 1bfd7317e6
commit 7193ffd250
3 changed files with 92 additions and 41 deletions

View File

@@ -161,114 +161,153 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
public MedicalSpecialtyTO getPOJOforMedicalSpecialtyJPA(MedicalSpecialtyJPA ms) { public MedicalSpecialtyTO getPOJOforMedicalSpecialtyJPA(MedicalSpecialtyJPA ms) {
MedicalSpecialtyTO msTO = null; MedicalSpecialtyTO msTO = null;
if (ms != null) { if (ms != null) {
msTO = new MedicalSpecialtyTO(ms.getId(), ms.getName(), ms.getDescription()); msTO = new MedicalSpecialtyTO(ms.getId(), ms.getName(), ms.getDescription());
} }
return msTO; return msTO;
} }
public PrimaryHealthCareCenterTO getPOJOforPrimaryHealthCareCenterJPA(PrimaryHealthCareCenterJPA phc) { public PrimaryHealthCareCenterTO getPOJOforPrimaryHealthCareCenterJPA(PrimaryHealthCareCenterJPA phc) {
PrimaryHealthCareCenterTO phcTO = null; PrimaryHealthCareCenterTO phcTO = null;
if (phc != null) { if (phc != null) {
phcTO = new PrimaryHealthCareCenterTO(phc.getId(), phc.getName(), phc.getLocation()); phcTO = new PrimaryHealthCareCenterTO(phc.getId(), phc.getName(), phc.getLocation());
} }
return phcTO; return phcTO;
} }
public SpecialistDoctorTO getPOJOforSpecialistDoctorJPA(SpecialistDoctorJPA sd, int nestedProps) { public SpecialistDoctorTO getPOJOforSpecialistDoctorJPA(SpecialistDoctorJPA sd, int nestedProps) {
SpecialistDoctorTO sdTO = null; SpecialistDoctorTO sdTO = null;
if (sd != null) { if (sd != null) {
MedicalSpecialtyJPA ms = null; MedicalSpecialtyJPA ms = null;
if (nestedProps > 0) if (nestedProps > 0)
ms = sd.getMedicalSpecialty(); ms = sd.getMedicalSpecialty();
nestedProps--; nestedProps--;
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getProfessionalNumber(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(), this.getPOJOforMedicalSpecialtyJPA(ms)); sdTO = new SpecialistDoctorTO(sd.getId(), sd.getProfessionalNumber(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(),
this.getPOJOforMedicalSpecialtyJPA(ms));
} }
return sdTO; return sdTO;
} }
public FamilyDoctorTO getPOJOforFamilyDoctorJPA(FamilyDoctorJPA fd, int nestedProps) { public FamilyDoctorTO getPOJOforFamilyDoctorJPA(FamilyDoctorJPA fd, int nestedProps) {
FamilyDoctorTO fdTO = null; FamilyDoctorTO fdTO = null;
if (fd != null) { if (fd != null) {
PrimaryHealthCareCenterJPA phc = null; PrimaryHealthCareCenterJPA phc = null;
if (nestedProps > 0) if (nestedProps > 0)
phc = fd.getPrimaryHealthCareCenter(); phc = fd.getPrimaryHealthCareCenter();
nestedProps--; 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; return fdTO;
} }
public PatientTO getPOJOforPatientJPA(PatientJPA pat, int nestedProps) { public PatientTO getPOJOforPatientJPA(PatientJPA pat, int nestedProps) {
PatientTO paTO = null; PatientTO paTO = null;
if (pat != null) { if (pat != null) {
FamilyDoctorJPA fd = null; FamilyDoctorJPA fd = null;
if (nestedProps > 0) if (nestedProps > 0)
fd = pat.getFamilyDoctor(); fd = pat.getFamilyDoctor();
nestedProps--; 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; return paTO;
} }
public PatientTO findPatientById(int patientId) { public PatientTO findPatientById(int patientId) {
// Recuperamos propiedades anidadas 1 nivel! // Recuperamos propiedades anidadas 1 nivel!
return this.getPOJOforPatientJPA(entman.find(PatientJPA.class, patientId), 1); 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); TypedQuery<PatientJPA> query = entman.createQuery("from PatientJPA pat where pat.personalIdentificationCode=:code", PatientJPA.class);
query.setMaxResults(1);
query.setParameter("code", code); query.setParameter("code", code);
List<PatientJPA> results = query.getResultList(); List<PatientJPA> results = query.getResultList();
if (results.size() > 0) if (results.size() > 0)
return results.get(0); return this.getPOJOforPatientJPA(results.get(0), 1);
else 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) { public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId) {
return this.getPOJOforFamilyDoctorJPA(entman.find(FamilyDoctorJPA.class, ProfessionalNumberId), 1); 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); TypedQuery<FamilyDoctorJPA> query = entman.createQuery("from FamilyDoctorJPA d where d.professionalNumber=:code", FamilyDoctorJPA.class);
query.setParameter("code", code); query.setParameter("code", code);
List<FamilyDoctorJPA> results = query.getResultList(); List<FamilyDoctorJPA> results = query.getResultList();
if (results.size() > 0) if (results.size() > 0)
return results.get(0); return this.getPOJOforFamilyDoctorJPA(results.get(0), 1);
else else
return null; 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) { public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId) {
return this.getPOJOforSpecialistDoctorJPA(entman.find(SpecialistDoctorJPA.class, ProfessionalNumberId), 1); 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); TypedQuery<SpecialistDoctorJPA> query = entman.createQuery("from SpecialistDoctorJPA d where d.professionalNumber=:code", SpecialistDoctorJPA.class);
query.setParameter("code", code); query.setParameter("code", code);
List<SpecialistDoctorJPA> results = query.getResultList(); List<SpecialistDoctorJPA> results = query.getResultList();
if (results.size() > 0) 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 else
return null; return null;
} }

View File

@@ -44,15 +44,21 @@ public interface CommonFacadeLocal {
public PatientTO findPatientById(int patientId); 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 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 SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId);
public SpecialistDoctorJPA findSpecialistDoctorByCode(String code); public SpecialistDoctorTO findSpecialistDoctorByCode(String code);
public SpecialistDoctorTO findSpecialistDoctorByNif(String searchValue);
public MedicalSpecialtyTO getPOJOforMedicalSpecialtyJPA(MedicalSpecialtyJPA ms); public MedicalSpecialtyTO getPOJOforMedicalSpecialtyJPA(MedicalSpecialtyJPA ms);

View File

@@ -42,14 +42,20 @@ public interface CommonFacadeRemote {
public PatientTO findPatientById(int patientId); 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 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 SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId);
public SpecialistDoctorJPA findSpecialistDoctorByCode(String code); public SpecialistDoctorTO findSpecialistDoctorByCode(String code);
public SpecialistDoctorTO findSpecialistDoctorByNif(String searchValue);
} }