Package open.dolphin.delegater

Source Code of open.dolphin.delegater.PVTDelegater

package open.dolphin.delegater;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.naming.NamingException;
import open.dolphin.dto.PatientVisitSpec;
import open.dolphin.ejb.RemotePvtService;
import open.dolphin.infomodel.HealthInsuranceModel;
import open.dolphin.infomodel.ModelUtils;
import open.dolphin.infomodel.PVTHealthInsuranceModel;
import open.dolphin.infomodel.PatientModel;
import open.dolphin.infomodel.PatientVisitModel;
import org.apache.log4j.Logger;

/**
* User 関連の Business Delegater クラス。
*
* @author Kazushi Minagawa, Digital Globe, Inc.
*/
public class PVTDelegater extends BusinessDelegater {
   
    private Logger logger;

   
    public void setLogger(Logger l) {
        logger = l;
    }
   
    /**
     * 受付情報 PatientVisitModel をデータベースに登録する。
     * @param pvtModel   受付情報 PatientVisitModel
     * @param principal  UserId と FacilityId
     * @return 保存に成功した個数
     */
    public int addPvt(PatientVisitModel pvtModel) {
       
        int retCode = 0;
       
        try {
            retCode = getService().addPvt(pvtModel);
            if (logger != null && logger.isDebugEnabled()) {
                logger.info("受付情報を保存しました。");
            }
           
        } catch (NamingException e) {
            if (logger != null && logger.isDebugEnabled()) {
                logger.warn("受付情報の保存に失敗しました");
                logger.warn(e.toString());
            }
            e.printStackTrace(System.err);
            processError(e);
        }
       
        return retCode;
    }
   
    /**
     * 来院情報をデータベースから取得する。
     * @param date     検索する来院日
     * @param firstRecord 何番目のレコードから取得するか
     * @return PatientVisitModel のコレクション
     */
    @SuppressWarnings("unchecked")
    public Collection<PatientVisitModel> getPvt(String[] date, int firstRecord) {
       
        PatientVisitSpec spec = new PatientVisitSpec();
        spec.setDate(date[0]);
        spec.setAppodateFrom(date[1]);
        spec.setAppodateTo(date[2]);
        spec.setSkipCount(firstRecord);
       
        try {
            Collection<PatientVisitModel> ret = getService().getPvt(spec);
           
            // 健康保険情報は,カルテオープン時に取得する
            //for (PatientVisitModel model : ret) {
            //    PatientModel patient = model.getPatient();
            //    decodeHealthInsurance(patient);
            //}
           
            return ret;
           
        } catch (NamingException e) {
            e.printStackTrace(System.err);
            processError(e);
        }
       
        return null;
    }
   
   
    /**
     * バイナリの健康保険データをオブジェクトにデコードする。
     * @param patient 患者モデル
     */
    private void decodeHealthInsurance(PatientModel patient) {
       
        // Health Insurance を変換をする beanXML2PVT
        List<HealthInsuranceModel> c = (List<HealthInsuranceModel>) patient.getHealthInsurances();
       
        if (c != null) {
            List<PVTHealthInsuranceModel> pvtHealthInsurances = ModelUtils.decodeHealthInsurance(c);           
            patient.setPvtHealthInsurances(pvtHealthInsurances);
            patient.setHealthInsurances(null);
        }
    }
   
    private int removePvt(long id) {
        try {
            return getService().removePvt(id);
        } catch (NamingException e) {
            e.printStackTrace(System.err);
            processError(e);
        }
        return 0;
    }
   
    public int updatePvtState(long pk, int state) {
        try {
            return getService().updatePvtState(pk, state);
        } catch (NamingException e) {
            e.printStackTrace(System.err);
            processError(e);
        }
        return 0;
    }

    public int setByomeiCount(long pk, int total, int today) {
        try {
            return getService().setByomeiCount(pk, total, today);
        } catch (NamingException e) {
            e.printStackTrace(System.err);
            processError(e);
        }
        return 0;
    }
    public ArrayList<Integer> getPvtState() {
        try {
            return getService().getPvtState();
        } catch (NamingException e) {
            e.printStackTrace(System.err);
            processError(e);
        }
        return null;
    }
    public int getPvtState(long pk) {
        try {
            return getService().getPvtState(pk);
        } catch (NamingException e) {
            e.printStackTrace(System.err);
            processError(e);
        }
        return -1;
    }
    public PatientVisitModel getPvt(PatientModel patient) {
        try {
            return getService().getPvt(patient);
        } catch (NamingException e) {
            e.printStackTrace(System.err);
            processError(e);
        }
        return null;
    }
   
    private RemotePvtService getService() throws NamingException {
        return (RemotePvtService)getService("RemotePvtService");
    }
}
TOP

Related Classes of open.dolphin.delegater.PVTDelegater

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.