Comprobación de médicos de familia asignados a centros al liminar un
CAP. Corregido error al obtener la cuenta de médicos de familia por CAP.
This commit is contained in:
@@ -230,6 +230,13 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
|||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getFamilyDoctorsByCAPCount(int primaryHealthCareCenterId) {
|
||||||
|
TypedQuery<Long> query = entman.createQuery("SELECT count(1) from FamilyDoctorJPA d where d.primaryHealthCareCenter.id=:capId", Long.class);
|
||||||
|
query.setParameter("capId", primaryHealthCareCenterId);
|
||||||
|
|
||||||
|
return query.getSingleResult();
|
||||||
|
}
|
||||||
|
|
||||||
public List<FamilyDoctorTO> listAllFamilyDoctorsByCAPPaged(int primaryHealthCareCenterId, int pageNumber, int pageSize) {
|
public List<FamilyDoctorTO> listAllFamilyDoctorsByCAPPaged(int primaryHealthCareCenterId, int pageNumber, int pageSize) {
|
||||||
List<FamilyDoctorTO> familyDoctorsByCAP = new ArrayList<FamilyDoctorTO>();
|
List<FamilyDoctorTO> familyDoctorsByCAP = new ArrayList<FamilyDoctorTO>();
|
||||||
|
|
||||||
|
|||||||
@@ -22,32 +22,34 @@ public interface SystemAdminFacadeRemote {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public LoggedUserTO login(String id, String pwd);
|
public LoggedUserTO login(String id, String pwd);
|
||||||
|
|
||||||
public MedicalSpecialtyTO updateSpecialty(int id, String name, String description) throws Exception;
|
public MedicalSpecialtyTO updateSpecialty(int id, String name, String description) throws Exception;
|
||||||
|
|
||||||
public MedicalSpecialtyTO findSpecialtyByName(String name);
|
public MedicalSpecialtyTO findSpecialtyByName(String name);
|
||||||
|
|
||||||
public void deleteSpecialty(int id) throws Exception;
|
public void deleteSpecialty(int id) throws Exception;
|
||||||
|
|
||||||
public MedicalSpecialtyTO insertSpecialty(String name, String description) throws Exception;
|
public MedicalSpecialtyTO insertSpecialty(String name, String description) throws Exception;
|
||||||
|
|
||||||
public PrimaryHealthCareCenterTO updateHealthCareCenter(int id, String name, String location) throws Exception;
|
public PrimaryHealthCareCenterTO updateHealthCareCenter(int id, String name, String location) throws Exception;
|
||||||
|
|
||||||
public PrimaryHealthCareCenterTO findHealthCareCenterByName(String name);
|
public PrimaryHealthCareCenterTO findHealthCareCenterByName(String name);
|
||||||
|
|
||||||
public void deleteHealthCareCenter(int id) throws Exception;
|
public void deleteHealthCareCenter(int id) throws Exception;
|
||||||
|
|
||||||
public PrimaryHealthCareCenterTO insertHealthCareCenter(String name, String location) throws Exception;
|
public PrimaryHealthCareCenterTO insertHealthCareCenter(String name, String location) throws Exception;
|
||||||
|
|
||||||
public Long getCAPCount();
|
public Long getCAPCount();
|
||||||
|
|
||||||
public List<PrimaryHealthCareCenterTO> listCAPsPaged(int pageNumber, int pageSize);
|
public List<PrimaryHealthCareCenterTO> listCAPsPaged(int pageNumber, int pageSize);
|
||||||
|
|
||||||
|
public Long getFamilyDoctorsByCAPCount(int primaryHealthCareCenterId);
|
||||||
|
|
||||||
public List<FamilyDoctorTO> listAllFamilyDoctorsByCAPPaged(int primaryHealthCareCenterId, int pageNumber, int pageSize);
|
public List<FamilyDoctorTO> listAllFamilyDoctorsByCAPPaged(int primaryHealthCareCenterId, int pageNumber, int pageSize);
|
||||||
|
|
||||||
public Long getPatientCount(int familyDoctorId);
|
public Long getPatientCount(int familyDoctorId);
|
||||||
|
|
||||||
public SystemAdminTO findAdminByEmail(String email);
|
public SystemAdminTO findAdminByEmail(String email);
|
||||||
|
|
||||||
public SystemAdminTO insertAdmin(String email, String password) throws Exception;
|
public SystemAdminTO insertAdmin(String email, String password) throws Exception;
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ public class ListDoctorsByCenterMBean extends ManagedBeanBase implements Seriali
|
|||||||
this.setRowCount(0);
|
this.setRowCount(0);
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
Long totalRowCount = getRemoteManagerMedicalTest().getSpecialistDoctorByMedicalSpecialtyCount(primaryHealthCareCenter.getId());
|
Long totalRowCount = getRemoteManagerSystemAdmin().getFamilyDoctorsByCAPCount(primaryHealthCareCenter.getId());
|
||||||
this.setRowCount(totalRowCount.intValue());
|
this.setRowCount(totalRowCount.intValue());
|
||||||
|
|
||||||
return getRemoteManagerSystemAdmin().listAllFamilyDoctorsByCAPPaged(primaryHealthCareCenter.getId(), (first / pageSize), pageSize);
|
return getRemoteManagerSystemAdmin().listAllFamilyDoctorsByCAPPaged(primaryHealthCareCenter.getId(), (first / pageSize), pageSize);
|
||||||
|
|||||||
@@ -98,8 +98,8 @@ public class ManageHealthCareCentersMBean extends ManagedBeanBase implements Ser
|
|||||||
public void setPrimaryHealthCareCenter(PrimaryHealthCareCenterTO value) {
|
public void setPrimaryHealthCareCenter(PrimaryHealthCareCenterTO value) {
|
||||||
this.primaryHealthCareCenter = value;
|
this.primaryHealthCareCenter = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onRowEdit(RowEditEvent event) {
|
public void onRowEdit(RowEditEvent event) {
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
if (((PrimaryHealthCareCenterTO) event.getObject()).getName() == null || ((PrimaryHealthCareCenterTO) event.getObject()).getName().trim().length() == 0) {
|
if (((PrimaryHealthCareCenterTO) event.getObject()).getName() == null || ((PrimaryHealthCareCenterTO) event.getObject()).getName().trim().length() == 0) {
|
||||||
@@ -113,35 +113,44 @@ public class ManageHealthCareCentersMBean extends ManagedBeanBase implements Ser
|
|||||||
|
|
||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
try {
|
try {
|
||||||
this.getRemoteManagerSystemAdmin().updateHealthCareCenter(((PrimaryHealthCareCenterTO) event.getObject()).getId(), ((PrimaryHealthCareCenterTO) event.getObject()).getName(),
|
this.getRemoteManagerSystemAdmin().updateHealthCareCenter(((PrimaryHealthCareCenterTO) event.getObject()).getId(),
|
||||||
((PrimaryHealthCareCenterTO) event.getObject()).getLocation());
|
((PrimaryHealthCareCenterTO) event.getObject()).getName(), ((PrimaryHealthCareCenterTO) event.getObject()).getLocation());
|
||||||
|
|
||||||
this.showPrimaryHealthCareCenterData(null);
|
this.showPrimaryHealthCareCenterData(null);
|
||||||
|
|
||||||
FacesMessage msg = new FacesMessage("CAP editado", ((PrimaryHealthCareCenterTO) event.getObject()).getName());
|
FacesMessage msg = new FacesMessage("CAP editado", ((PrimaryHealthCareCenterTO) event.getObject()).getName());
|
||||||
FacesContext.getCurrentInstance().addMessage(null, msg);
|
FacesContext.getCurrentInstance().addMessage(null, msg);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
this.manageException(e);
|
this.manageException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onRowCancel(RowEditEvent event) {
|
public void onRowCancel(RowEditEvent event) {
|
||||||
FacesMessage msg = new FacesMessage("Edición cancelada", ((PrimaryHealthCareCenterTO) event.getObject()).getName());
|
FacesMessage msg = new FacesMessage("Edición cancelada", ((PrimaryHealthCareCenterTO) event.getObject()).getName());
|
||||||
FacesContext.getCurrentInstance().addMessage(null, msg);
|
FacesContext.getCurrentInstance().addMessage(null, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteDataById(Integer id) throws IOException {
|
public void deleteDataById(Integer id) throws IOException {
|
||||||
|
int error = 0;
|
||||||
try {
|
try {
|
||||||
this.getRemoteManagerSystemAdmin().deleteHealthCareCenter(id);
|
if (this.getRemoteManagerSystemAdmin().getFamilyDoctorsByCAPCount(id) > 0) {
|
||||||
this.showPrimaryHealthCareCenterData(null);
|
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "No se puede eliminar este CAP",
|
||||||
|
"Existen médicos de familia asignados a este CPA, por lo cual no se puede eliminar. Asigne los médicos a otro CAP para proceder a eliminar el CAP a continuación.");
|
||||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "El CAP se ha borrado", "Los datos del Centro de Atención Primaria se han borrado correctamente.");
|
error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error == 0) {
|
||||||
|
this.getRemoteManagerSystemAdmin().deleteHealthCareCenter(id);
|
||||||
|
this.showPrimaryHealthCareCenterData(null);
|
||||||
|
|
||||||
|
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "El CAP se ha borrado", "Los datos del Centro de Atención Primaria se han borrado correctamente.");
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
this.manageException(e);
|
this.manageException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertData() {
|
public void insertData() {
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user