Preguntas y respuestas funcionando para médicos
This commit is contained in:
@@ -74,11 +74,35 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
* @param response
|
||||
*/
|
||||
@Override
|
||||
public void answerQuestion(String question, String response) {
|
||||
public void answerQuestion(QuestionTO q) {
|
||||
QuestionJPA qjpa = entman.find(QuestionJPA.class, q.getId());
|
||||
qjpa.setResponse(q.getResponse());
|
||||
qjpa.setStatus(QuestionStatus.ANSWERED);
|
||||
|
||||
PatientJPA patient = entman.find(PatientJPA.class, q.getPatient().getId());
|
||||
// 1. Buscar el médico de familia con ese professionalNumber
|
||||
FamilyDoctorJPA fdoctor = entman.find(FamilyDoctorJPA.class, q.getDoctor().getId());
|
||||
|
||||
qjpa.setPatient(patient);
|
||||
qjpa.setFamilyDoctor(fdoctor);
|
||||
|
||||
entman.persist(qjpa);
|
||||
}
|
||||
|
||||
public List<QuestionTO> listAllPendingQuestions(int familyDoctorId) {
|
||||
return null;
|
||||
// TypedQuery<QuestionJPA> query = entman.createQuery("SELECT q from QuestionJPA q where q.status=:status and q.familyDoctor.id=:docId order by q.title", QuestionJPA.class);
|
||||
TypedQuery<QuestionJPA> query = entman.createQuery("SELECT q from QuestionJPA q where q.familyDoctor.id=:docId order by q.status desc, q.title asc", QuestionJPA.class);
|
||||
// query.setParameter("status", QuestionStatus.PENDING);
|
||||
query.setParameter("docId", familyDoctorId);
|
||||
|
||||
List<QuestionJPA> allJPA = query.getResultList();
|
||||
List<QuestionTO> pendingQuestions = new ArrayList<QuestionTO>();
|
||||
|
||||
for (QuestionJPA item : allJPA) {
|
||||
pendingQuestions.add(commonServices.getPOJOforQuestionJPA(item, 1));
|
||||
}
|
||||
|
||||
return pendingQuestions;
|
||||
}
|
||||
|
||||
public Long getPendingQuestionsCount(int familyDoctorId) {
|
||||
|
||||
@@ -37,7 +37,7 @@ public interface MedicalTestFacadeRemote {
|
||||
* @param question
|
||||
* @param response
|
||||
*/
|
||||
public void answerQuestion(String question, String response);
|
||||
public void answerQuestion(QuestionTO question);
|
||||
|
||||
/**
|
||||
* Recuperar las preguntas sin respuesta para un médico
|
||||
|
||||
Reference in New Issue
Block a user