/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package web.reception;
import domain.Client;
import domain.Lpu;
import domain.shedule.WorkType;
import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import web.generic.CH;
import web.generic.GenericAbstractController;
import web.rechelper.IncomingParamsValidator;
/**
* Контроллер выбора типа приема
* Обязательные параметры:
* client - ID пациента
* Необязательные параметры:
* lpu - ID ЛПУ
* @author petr
*/
public class WorkController extends GenericAbstractController {
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Client client = CH.getOptional(getDao(), Client.class, request.getParameter("client"));
Lpu lpu = CH.getOptional(getDao(), Lpu.class, request.getParameter("lpu"));
if (client == null) {
return IncomingParamsValidator.redirectTo("/reception/index.htm", client, null, null, null);
}
HashMap model = new HashMap();
model.put("client", client);
model.put("lpu", lpu);
List<WorkType> aviableWorks = lpu != null ? getDao().getWorksByLpu(lpu) : getDao().getAviableWorks();
model.put("works", aviableWorks);
String nextUrl = lpu != null ? "/reception/collaborator.htm" : "/reception/lpu.htm";
model.put("nextUrl", nextUrl);
model.put("pageBreadcrumb", ReceptionController.initBreadCrumb(client, null, lpu, null));
return new ModelAndView("reception/work", model);
}
}