Package clips.delegate.doctor.prescriptiondlo

Source Code of clips.delegate.doctor.prescriptiondlo.PrescriptionDloLocal

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

package clips.delegate.doctor.prescriptiondlo;

import beans.doctor.prescriptiondlo.PrescriptionDloBean;
import beans.doctor.prescriptiondlo.PrescriptionDloBeanRemote;
import beans.doctor.prescriptiondlo.PrescriptionDloDetails;
import cli_fmw.delegate.AuditListener;
import cli_fmw.delegate.cache.DelegateSecondaryCacheDgt;
import cli_fmw.delegate.directory.complex.DirectoryLocator;
import cli_fmw.delegate.utils.TimeLocal;
import cli_fmw.main.ClipsException;
import cli_fmw.main.DelegatePrintable;
import cli_fmw.report.CombinedReportCreator;
import cli_fmw.report.FormReportCreator;
import clips.delegate.DEC.DECServiceRender;
import clips.delegate.client.ClientLocal;
import clips.delegate.directory.complex.DirectoryDrugList;
import clips.delegate.directory.complex.DirectoryDrugListItem;
import clips.delegate.directory.ro.DirectoryCollaborator;
import clips.delegate.directory.ro.DirectoryCollaboratorItem;
import clips.delegate.directory.simple.financesource.DirectoryFinanceSource;
import clips.delegate.directory.simple.financesource.DirectoryFinanceSourceItem;
import clips.delegate.doctor.HasSerrenLocal;
import clips.delegate.doctor.Iconable;
import clips.delegate.doctor.Signable;
import clips.delegate.doctor.diagnosis.DiagnosisLocal;
import clips.delegate.kek.CommitteeLocal;
import clips.delegate.service.SerRenLocal;
import clips.doctor.newEMC.init.generic.DelegateNodeLeaf;
import clips.login.UserInfo;
import framework.utils.Converter;
import java.util.Date;
import java.util.HashMap;
import javax.swing.Icon;
import javax.swing.ImageIcon;

/**
*
* @author lacoste
*/
public class PrescriptionDloLocal extends
    DelegateNodeLeaf<PrescriptionDloBeanRemote, PrescriptionDloDetails>
        implements  Iconable, DelegatePrintable, HasSerrenLocal, Signable {

    private DECServiceRender serviceRender = new DECServiceRender(this, "информацию об услуге, в рамках которой назначен приём лекарств", getAuditListener());
    private static ImageIcon icon = null;

    public PrescriptionDloLocal(SerRenLocal serRen) throws ClipsException {
        super(serRen.getAuditListener());
        getDetails().date = TimeLocal.getCurrentTime().getTime();
        serviceRender.initBy(serRen);
    }

    public PrescriptionDloLocal(int id, SerRenLocal serRen, AuditListener al) throws ClipsException {
        super(id, al);
        serviceRender.initBy(serRen);
    }

    public PrescriptionDloLocal(PrescriptionDloDetails details, SerRenLocal serRen, AuditListener al) throws ClipsException {
        super(details, al);
        serviceRender.initBy(serRen);
    }

    @Override
    protected PrescriptionDloDetails getNewDetails() {
        return new PrescriptionDloDetails();
    }

    @Override
    public SerRenLocal getSerrenLocal() throws ClipsException {
        return serviceRender.get();
    }

    public Date getDate() throws ClipsException {
        return getDetails().date;
    }

    /**
     * Лекарственное средство из перечня
     * @return
     * @throws ClipsException
     */
    public DirectoryDrugListItem getDrug() throws ClipsException {
        if (getDetails().drugID != 0) {
            DirectoryDrugList dcf = DirectoryLocator.getDirectory(DirectoryDrugList.class);
            return dcf.getItemFromID(getDetails().drugID);
        } else {
            return null;
        }
    }

    /**
     * Лекарственное средство из перечня
     * @throws ClipsException
     */
    public void setDrug(DirectoryDrugListItem drug) throws ClipsException {
        getDetails().drugID = drug.getID();
        fireContentStateEvent();
    }

    public DirectoryCollaboratorItem getCollaborator() throws ClipsException {
        DirectoryCollaborator dir = DirectoryLocator.getDirectory(DirectoryCollaborator.class, false);
        return dir.getItemFromID(getDetails().collabID);
    }

    /**
     * Серия рецепта
     * @return
     * @throws ClipsException
     */
    public String getSeries() throws ClipsException {
        return getDetails().series;
    }

    /**
     * Серия рецепта
     * @throws ClipsException
     */
    public void setSeries(String series) throws ClipsException {
        getDetails().series = series;
        fireContentStateEvent();
    }

    /**
     * Номер рецепта
     * @return
     * @throws ClipsException
     */
    public String getNumber() throws ClipsException {
        return getDetails().number;
    }

    /**
     * Номер рецепта
     * @throws ClipsException
     */
    public void setNumber(String number) throws ClipsException {
        getDetails().number = number;
        fireContentStateEvent();
    }

    /**
     * Источник финансирования
     * @return
     * @throws ClipsException
     */
    public DirectoryFinanceSourceItem getFinance() throws ClipsException {
        DirectoryFinanceSource dfs = DirectoryLocator.getDirectory(DirectoryFinanceSource.class);
        return dfs.getItemFromID(getDetails().financeID);
    }

    /**
     * Источник финансирования
     * @throws ClipsException
     */
    public void setFinance(DirectoryFinanceSourceItem finance) throws ClipsException {
        getDetails().financeID = finance.getID();
        fireContentStateEvent();
    }

    /**
     * Процент льготы рецепта
     * @return
     * @throws ClipsException
     */
    public int getPercent() throws ClipsException {
        return getDetails().percent;
    }

    /**
     * Процент льготы рецепта
     * @throws ClipsException
     */
    public void setPercent(int percent) throws ClipsException {
        getDetails().percent = percent;
        fireContentStateEvent();
    }

    /**
     * Выписанное количество единиц лекарственной формы ЛС
     * @return
     * @throws ClipsException
     */
    public double getQuantity() throws ClipsException {
        return getDetails().quantity;
    }

    /**
     * Выписанное количество единиц лекарственной формы ЛС
     * @throws ClipsException
     */
    public void setQuantity(double quantity) throws ClipsException {
        getDetails().quantity = quantity;
        fireContentStateEvent();
    }

    /**
     * Срок действия рецепта, дней
     * @return
     * @throws ClipsException
     */
    public int getPeriod() throws ClipsException {
        return getDetails().period;
    }

    /**
     * Срок действия рецепта, дней
     * @throws ClipsException
     */
    public void setPeriod(int period) throws ClipsException {
        getDetails().period = period;
        fireContentStateEvent();
    }

   /**
     * Признак "Особый случай"
     * @return
     * @throws ClipsException
     */
    public String getSpecialCase() throws ClipsException {
        return getDetails().specialCase;
    }

    /**
     * Признак "Особый случай"
     * @throws ClipsException
     */
    public void setSpecialCase(String specialCase) throws ClipsException {
        getDetails().specialCase = specialCase;
        fireContentStateEvent();
    }

    public DiagnosisLocal getDiagnosis() throws ClipsException {
        return diagnosis.get();
    }

    public void setDiagnosis(DiagnosisLocal diag) throws ClipsException {
        diagnosis.set(diag);
        fireContentStateEvent();
    }

    private DelegateSecondaryCacheDgt<DiagnosisLocal> diagnosis
            = new DelegateSecondaryCacheDgt<DiagnosisLocal>(getSCM(), true, "диагноз выписки") {

        @Override
        protected DiagnosisLocal init() throws Exception {
            if (getDetails().diagnosisId != 0){
                return new DiagnosisLocal(getDetails().diagnosisId, getAuditListener());
            }else{
                return null;
            }
        }

        @Override
        protected void setPrimary(DiagnosisLocal diag) throws ClipsException {
            if (diag != null){
                getDetails().diagnosisId = diag.getID();
            }else{
                getDetails().diagnosisId = 0;
            }
        }
    };

    public CommitteeLocal getCommittee() throws ClipsException {
        return committee.get();
    }

    public void setCommittee(CommitteeLocal com) throws ClipsException {
        committee.set(com);
        fireContentStateEvent();
    }

    private DelegateSecondaryCacheDgt<CommitteeLocal> committee
            = new DelegateSecondaryCacheDgt<CommitteeLocal>(getSCM(), true, "заседание КЭК") {

        @Override
        protected CommitteeLocal init() throws Exception {
            if (getDetails().kekID != 0){
                return new CommitteeLocal(getDetails().kekID, getAuditListener());
            }else{
                return null;
            }
        }

        @Override
        protected void setPrimary(CommitteeLocal kek) throws ClipsException {
            if (kek != null){
                getDetails().kekID = kek.getID();
            }else{
                getDetails().kekID = 0;
            }
        }
    };

    @Override
    public Icon getIcon() {
        return icon;
    }

    @Override
    public String toString() {
        return "Льготный рецепт";
    }

    @Override
    protected String getBeanName() {
        return PrescriptionDloBean.class.getSimpleName();
    }

    @Override
    public void print(CombinedReportCreator cCreator) throws ClipsException {
        HashMap<String, Object> data = getSerrenLocal().getPolisData().getClient().getPrintFields();

        ClientLocal client = getSerrenLocal().getPolisData().getClient();
        String fio = client.getSurname().getTitle()
                + " " + client.getName().getTitle()
                + " " + client.getPathron().getTitle();
        data.put("pacient_fio", fio);

        //TODO
        data.put("hospital_stamp", UserInfo.get().getCollaborator().getLpu().getLpuCode());
        //ENDTODO

        String code = getDiagnosis().getMkb().getDiseaseCode();
        data.put("mkb_code", code);

        int finance = getFinance().getID();
        data.put("finance_source", finance);
        int percent = getPercent();
        data.put("percent", percent);

        String series = getSeries();
        data.put("reception_series", series);
        String number = getNumber();
        data.put("reception_number", number);
        Date date = getDate();
        data.put("reception_date", Converter.dateToString(date));

        data.put("collaborator_fio", getCollaborator().toString());
        data.put("collaborator_code", getCollaborator().getCode());

        DirectoryDrugListItem drug = getDrug();
        String str = drug.getMnn() != null ? drug.getMnn().getTitle() : null;
        if (str == null) {
            str = drug.getTradeName() != null ? drug.getTradeName().getTitle() : "";
        }
        data.put("rp", str);

        if (drug.getDosage() != null) {
            data.put("dosage", drug.getDosage());
        }

        str = "" + (drug.getDosageQuantity() != 0 ? drug.getDosageQuantity() : "");
        data.put("quantity", str);

        str = "" + (drug.getDosageUnit() != null ? drug.getDosageUnit().getTitle() : "");
        data.put("signa", str);

        FormReportCreator creater = cCreator.createFormReporter(getClass(), 1);
        creater.createReport(null, null, data.entrySet(), null);
        creater.finish();
    }

    @Override
    public boolean isSignCorrect() throws ClipsException{
        //STUB
        return (getID() != -1 );
        //END STUB
    }

    @Override
    public String getSignMessage() throws ClipsException {
        if (getID() == 0) {
            return "Подпись отсутствует";
        }
        //STUB
        String coll;
        if (getSerrenLocal().getCollaboratorFunctions() != null) {
            coll = getSerrenLocal().getCollaboratorFunctions().getTitle();
        } else {
            coll = getSerrenLocal().getSerRenDirector().getTitle();
        }

        String s = "Подписано " + Converter.dateToString(getDate())
                + " - " + coll;
        if (isSignCorrect() ) {
            return s;
        } else {
            return "Подпись не соответствует данным!";
        }
        //END STUB
    }

}
TOP

Related Classes of clips.delegate.doctor.prescriptiondlo.PrescriptionDloLocal

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.