Package beans.doctor.prescriptiondlo

Source Code of beans.doctor.prescriptiondlo.PrescriptionDloBean

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

package beans.doctor.prescriptiondlo;

import beans.cec.entity.Committee;
import beans.directory.dlodruglist.DloDrugList;
import beans.directory.simple.entities.FinanceSource;
import beans.doctor.MedicalDataBean;
import beans.doctor.diagnosis.Diagnosis;
import beans.service.ServiceRender;
import beans.user.collaborator.entities.Collaborator;
import framework.audit.AuditDoc;
import framework.beans.EntityDetails;
import framework.generic.ClipsServerException;
import framework.generic.ESecurity;
import java.util.Date;
import java.util.List;
import javax.ejb.Stateful;

/**
*
* @author lacoste
*/
@Stateful(mappedName="clips-beans/PrescriptionDloBean")
public class PrescriptionDloBean extends MedicalDataBean<PrescriptionDlo>
        implements PrescriptionDloBeanRemote {

    public PrescriptionDloBean() {
        super(PrescriptionDlo.class);
    }

    @Override
    protected void onUpdate(PrescriptionDlo entity, EntityDetails details,
            AuditDoc auditDoc, List<AuditDoc> audit) throws ClipsServerException {
        super.onUpdate(entity, details, auditDoc, audit);
        PrescriptionDloDetails d = (PrescriptionDloDetails) details;

        if (d.drugID == 0) {
            throw new ClipsServerException("Не указано лекарственное средство");
        }

        if (d.diagnosisId == 0) {
            throw new ClipsServerException("Необходимо указать диагноз");
        }

        if (d.financeID == 0) {
            throw new ClipsServerException("Не указан источник финансирования");
        }

        if(entity.getId() != 0) {
            if(entity.getServiceRender().getId() != d.serviceRenderID) {
                throw new ESecurity("Cмена услуги недопустима");
            }
        }
        entity.setDrug(findEntity(DloDrugList.class, d.drugID));
        entity.setServiceRender(findEntity(ServiceRender.class, d.serviceRenderID));
        entity.setDiagnosis(findEntity(Diagnosis.class, d.diagnosisId));
        entity.setDate(new Date());
        entity.setSeries(d.series);
        entity.setNumber(d.number);
        entity.setFinance(findEntity(FinanceSource.class, d.financeID));
        entity.setPercent(d.percent);
        entity.setQuantity(d.quantity);
        entity.setPeriod(d.period);
        entity.setKek(d.kekID != 0 ? findEntity(Committee.class, d.kekID) : null);
        entity.setSpecialCase(d.specialCase);
        entity.setCollaborator(findEntity(Collaborator.class, getCollaboratorId()));
    }

    @Override
    protected void onRemove(PrescriptionDlo entity, List<AuditDoc> audit) throws ClipsServerException {
        super.onRemove(entity, audit);
    }

}
TOP

Related Classes of beans.doctor.prescriptiondlo.PrescriptionDloBean

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.