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>();
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ public interface SystemAdminFacadeRemote {
|
|||||||
|
|
||||||
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);
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -113,8 +113,8 @@ 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);
|
||||||
|
|
||||||
@@ -132,11 +132,20 @@ public class ManageHealthCareCentersMBean extends ManagedBeanBase implements Ser
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void deleteDataById(Integer id) throws IOException {
|
public void deleteDataById(Integer id) throws IOException {
|
||||||
|
int error = 0;
|
||||||
try {
|
try {
|
||||||
|
if (this.getRemoteManagerSystemAdmin().getFamilyDoctorsByCAPCount(id) > 0) {
|
||||||
|
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.");
|
||||||
|
error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error == 0) {
|
||||||
this.getRemoteManagerSystemAdmin().deleteHealthCareCenter(id);
|
this.getRemoteManagerSystemAdmin().deleteHealthCareCenter(id);
|
||||||
this.showPrimaryHealthCareCenterData(null);
|
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.");
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user