Package clips.delegate.doctor.checkup

Source Code of clips.delegate.doctor.checkup.CheckupFactoryLocal

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package clips.delegate.doctor.checkup;

import beans.laboratory.CheckupSearchBean;
import beans.laboratory.CheckupSearchBeanRemote;
import clips.delegate.client.ClientLocal;
import cli_fmw.delegate.DelegateSimple;
import cli_fmw.main.ClipsException;
import clips.delegate.directory.filtered.DirectoryServiceItem;
import clips.delegate.service.SerRenLocal;
import beans.doctor.checkup.CheckupDetails;
import cli_fmw.main.audit.AuditManager;
import clips.delegate.directory.complex.DirectoryLaboratoryItem;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;

/**
* Делегат, выдающий загруженные списки анализов
* @author vip
*/
public class CheckupFactoryLocal extends DelegateSimple<CheckupSearchBeanRemote>{   

    public CheckupFactoryLocal(AuditManager am) throws ClipsException {
        super(CheckupSearchBean.class.getSimpleName());
        this.am = am;
        initBean();
    }

    public ArrayList<CheckupLocal> getAnalyseList(DirectoryLaboratoryItem laboratory,
            DirectoryServiceItem service, boolean rendered, Date from, Date to) throws ClipsException {

        int serID = service == null ? 0 : service.getID();
        int labID = laboratory.getID();

        //создадим хешмап услуг, чтобы 2 чекапа имеющие одинаковый ID услуги ссылались на один объект
        ArrayList<CheckupDetails> detailsList;
        HashMap<Integer, SerRenLocal> serrenMap = new HashMap<Integer, SerRenLocal>();
        try {
            detailsList = getBean().get().getAnalyseList(labID, serID, rendered, from, to);
        } catch (Exception ex) {
            clearBean();
            throw new ClipsException("Не удалось получить список анализов", ex);
        }
       
        for (int i = 0; i < detailsList.size(); i++) {
            int serrenID = detailsList.get(i).serviceRenderID;
            if (!serrenMap.containsKey(serrenID)) {
                SerRenLocal serren = new SerRenLocal(serrenID, am);
                serrenMap.put(serrenID, serren);
            }
        }
        //создаем список чекапов
        ArrayList<CheckupLocal> checkupList = new ArrayList<CheckupLocal>();
        for (int i = 0; i < detailsList.size(); i++) {
            int serrenID = detailsList.get(i).serviceRenderID;
            CheckupLocal checkup = new CheckupLocal(detailsList.get(i), serrenMap.get(serrenID), am);
            checkupList.add(checkup);
        }
        return checkupList;
    }
   
    /**
     * только анализы
     * @param client
     * @return
     * @throws generic.ClipsException
     */
    public ArrayList<CheckupLocal> getAnalyseList(ClientLocal client) throws ClipsException{
        int clientID = client == null ? 0 : client.getID();       
        ArrayList<CheckupDetails> detailsList;       
        ArrayList<CheckupLocal> checkupList = new ArrayList<CheckupLocal>();
       
        try {
            detailsList = getBean().get().getClientAnalyseList(clientID);
        } catch (Exception ex) {
            clearBean();
            throw new ClipsException("Не далось получить списки анализов пациента");
        }
       
        for (int i = 0; i < detailsList.size(); i++) {
            CheckupDetails d = detailsList.get(i);
            int serrenID = d.serviceRenderID;
            CheckupLocal checkup = new CheckupLocal(d, new SerRenLocal(serrenID, am), am);
            checkupList.add(checkup);
        }
        return checkupList;
    }

    /**
     * только чекапы
     * @param client
     * @return
     * @throws generic.ClipsException
     */
    public ArrayList<CheckupLocal> getCheckupList(ClientLocal client) throws ClipsException{
        int clientID = client == null ? 0 : client.getID();       
        ArrayList<CheckupDetails> detailsList;       
        ArrayList<CheckupLocal> checkupList = new ArrayList<CheckupLocal>();
        try {
            detailsList = getBean().get().getClientCheckupList(clientID);
        } catch (Exception ex) {
            clearBean();
            throw new ClipsException("Не удалось получить списки осмотров/анализов пациента", ex);
        }
        for (int i = 0; i < detailsList.size(); i++) {
            CheckupDetails d = detailsList.get(i);
            int serrenID = d.serviceRenderID;
            CheckupLocal checkup = new CheckupLocal(d, new SerRenLocal(serrenID, am), am);
            checkupList.add(checkup);
        }
        return checkupList;
    }

    /**
     * Загружает с сервера чекапы, являющиеся не проведенными анализами не
     * привязанные к расписанию. Чекапы, привязанные к просроченному расписанию
     * считаются тоже не привязанными.
     * @return
     * @throws ClipsException
     */
    public ArrayList<CheckupLocal> getFreeCheckupList() throws ClipsException {
        HashMap<Integer, SerRenLocal> serrenMap = new HashMap<Integer, SerRenLocal>();
       
        ArrayList<CheckupDetails> detailsList;       
        ArrayList<CheckupLocal> checkupList = new ArrayList<CheckupLocal>();
        try {
            detailsList = getBean().get().getFreeAnalysesList();
        } catch (Exception ex) {
            clearBean();
            throw new ClipsException("Не удалось получить анализы не привязанные к расписанию", ex);
        }
        for (int i = 0; i < detailsList.size(); i++) {
            CheckupDetails d = detailsList.get(i);
            int serrenID = d.serviceRenderID;
            if (serrenMap.get(serrenID) == null){
                serrenMap.put(serrenID, new SerRenLocal(serrenID, am));
            }           
            SerRenLocal srl = serrenMap.get(serrenID);
            System.out.println("Create checkup on serren: " + srl.getID());
            CheckupLocal checkup = new CheckupLocal(d, srl, am);
            checkupList.add(checkup);
        }
        System.out.println("==================getCheckUpList===================");
  
        for (int i = 0; i < checkupList.size(); i++) {
            CheckupLocal checkupLocal = checkupList.get(i);
            System.out.println("Load free checkup: " + checkupLocal.getID());
        }

        return checkupList;
    }
   
}
TOP

Related Classes of clips.delegate.doctor.checkup.CheckupFactoryLocal

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.