Package web.reception

Source Code of web.reception.LpuController

/*
* 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.ArrayList;
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 пациента
* Необязательные параметры:
*     type - ID типа приема
* @author petr
*/
public class LpuController extends GenericAbstractController {

    @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
       
        Client client = CH.getOptional(getDao(), Client.class, request.getParameter("client"));
        WorkType type = CH.getOptional(getDao(), WorkType.class, request.getParameter("type"));
        if (client == null) {
            return IncomingParamsValidator.redirectTo("/reception/index.htm", client, null, null, null);
        }

        HashMap model = new HashMap();
        model.put("client", client);
        model.put("type", type);

        List<Lpu> lpus = type != null ? getDao().getLpuByWorkType(type) : getDao().getAviableLpu();
        if (client.getDistrict() != null){
            Lpu userLpu = client.getDistrict().getLpu();
            model.put("userLpu", userLpu);
            model.put("userLpuAddress", userLpu.getAddress().getAsStringShort());
            for (int i = 0; i < lpus.size(); i++) {
                Lpu lpu = lpus.get(i);
                if (lpu.getId() == userLpu.getId()){
                    lpus.remove(i);
                    break;
                }
            }
        }

        List<LpuRenderDTO> lines = new ArrayList<LpuRenderDTO>();
        for (Lpu lpu : lpus) {
            lines.add(new LpuRenderDTO(lpu, lpu.getAddress().getAsStringShort()));
        }

        model.put("lpus", lines);

        String nextUrl = type == null ? "/reception/work.htm": "/reception/collaborator.htm";
        model.put("nextUrl", nextUrl);

        model.put("pageBreadcrumb", ReceptionController.initBreadCrumb(client, type, null, null));

        return new ModelAndView("reception/lpu", model);
    }

}
TOP

Related Classes of web.reception.LpuController

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.