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

@@ -188,7 +188,8 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
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;
@@ -203,7 +204,8 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
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;
@@ -218,7 +220,8 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
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;
@@ -229,30 +232,54 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
return this.getPOJOforPatientJPA(entman.find(PatientJPA.class, patientId), 1); return this.getPOJOforPatientJPA(entman.find(PatientJPA.class, patientId), 1);
} }
public PatientTO findPatientByCode(String code) {
public PatientJPA 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
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 else
return null; return null;
} }
@@ -261,14 +288,26 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
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);
} }