Package clips.delegate.doctor.contraindication

Source Code of clips.delegate.doctor.contraindication.ContraindicationLocal

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

package clips.delegate.doctor.contraindication;

import beans.doctor.contraindication.ContraindicationBean;
import beans.doctor.contraindication.ContraindicationDetails;
import beans.doctor.contraindication.ContraindicationBeanRemote;
import cli_fmw.delegate.AuditListener;
import cli_fmw.delegate.DelegateLine2;
import cli_fmw.delegate.directory.complex.DirectoryLocator;
import clips.delegate.doctor.HasSerrenLocal;
import clips.delegate.doctor.Iconable;
import clips.delegate.service.SerRenLocal;
import cli_fmw.delegate.utils.TimeLocal;
import cli_fmw.main.ClipsException;
import cli_fmw.main.DelegatePrintable;
import clips.delegate.DEC.DECServiceRender;
import clips.delegate.directory.filtered.DirectoryMatter;
import clips.delegate.directory.filtered.DirectoryMatterItem;
import cli_fmw.report.CombinedReportCreator;
import cli_fmw.report.FormReportCreator;
import cli_fmw.report.TableReportOptions;
import clips.doctor.newEMC.init.generic.DelegateNodeLeaf;
import clips.delegate.doctor.Signable;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import framework.utils.Converter;



/**
* Делегат, предоставляющий доступ к одной строке таблицы contraindication
* (Непереносимости действующих веществ)
* @author ViP
*/

public class ContraindicationLocal  extends
        DelegateNodeLeaf<ContraindicationBeanRemote, ContraindicationDetails>
        implements Iconable, DelegatePrintable, HasSerrenLocal, Signable {
   
    private DECServiceRender serviceRender = new DECServiceRender(this, "информацию об услуге, в рамках которой выявлена непереносимость", getAuditListener());
    public static ImageIcon icon = null;

    /**
     * Создает новую непереносимость в рамках указанной услуги
     * @param serRen услуга, в рамках которой зарегистрирована непереносимость
     * @throws ClipsException
     */
    public ContraindicationLocal(SerRenLocal serRen) throws ClipsException {
        super(serRen.getAuditListener());
        serviceRender.initBy(serRen);
        getDetails().date = TimeLocal.getCurrentTime().getTime();
    }
   
    public ContraindicationLocal(int id, SerRenLocal serRen, AuditListener al) throws ClipsException {
        super(id, al);
        serviceRender.initBy(serRen);
        getDetails().date = TimeLocal.getCurrentTime().getTime();
    }

    public ContraindicationLocal(ContraindicationDetails details, SerRenLocal serRen, AuditListener al) throws ClipsException {
        super(details, al);
        if (serRen != null) {
            serviceRender.initBy(serRen);
        }
    }

    @Override
    protected ContraindicationDetails getNewDetails() {
        return new ContraindicationDetails();
    }
  
    public Date getDate() throws ClipsException {
        return getDetails().date;
    }
   
    //Never use client Date
    @Deprecated
    public void setDate(Date date) throws ClipsException {
        getDetails().date = date;
        fireContentStateEvent();
    }

    public DirectoryMatterItem getMatter() throws ClipsException {        
        DirectoryMatter matterList = (DirectoryMatter) DirectoryLocator.getDirectory(DirectoryMatter.class, false);
        return matterList.getItemFromID(getDetails().matter);
    }
    public void setMatter(DirectoryMatterItem matter) throws ClipsException {
        getDetails().matter = matter.getID();
        fireContentStateEvent();
    }

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

    @Override
    public String toString() {
        return "Непереносимость";
    }

    @Override
    protected String getBeanName() {
        return ContraindicationBean.class.getSimpleName();
    }
   
    @Override
    public void print(CombinedReportCreator cCreator) throws ClipsException {
        FormReportCreator creater = cCreator.createFormReporter(getClass(), 1);
        TableReportOptions ops = new TableReportOptions();
        ops.topMargin = 0;
        ops.bottomMargin = 0;
        HashMap<String, Object> data = new LinkedHashMap<String, Object>();
        String title = "Данные непереносимости действующих веществ";
        data.put("client", "Пациент: " + getSerrenLocal().getPolisData().getClient(getAuditListener()).toString());
        data.put("date", "Дата выписки: " + Converter.dateToString(getDate()));
        data.put("contraindication", "Непереносимость действующего вещества: " + getMatter().getTitle());
        creater.createReport(title, ops, 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.contraindication.ContraindicationLocal

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.