/*
* SerRenLocal.java
*
* Created on 17 Декабрь 2007 г., 14:02
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package clips.delegate.service;
import beans.contract.entity.Contract;
import beans.contract.entity.PolisDetails;
import beans.discount.entity.DiscountCardDetails;
import beans.expenditure.entity.ExpenditureDetails;
import beans.service.ServiceRenderBean;
import beans.service.ServiceRenderBeanRemote;
import cli_fmw.delegate.cache.SecondaryCacheManager;
import cli_fmw.utils.SelectorEditable;
import beans.service.ServiceRenderDetails;
import clips.delegate.service.discount.DiscountCardLocal;
import cli_fmw.main.ClipsException;
import clips.delegate.contract.PolisData;
import clips.delegate.contract.ServisePriceData;
import cli_fmw.delegate.directory.complex.DirectoryLocator;
import clips.delegate.directory.filtered.DirectoryService;
import clips.delegate.directory.filtered.DirectoryServiceItem;
import clips.delegate.doctor.contraindication.ContraindicationLocal;
import clips.delegate.doctor.direction.DirectionLocal;
import clips.delegate.doctor.RecommendationLocal;
import clips.delegate.expenditure.ExpenditureItemData;
import clips.delegate.doctor.checkup.CheckupLocal;
import clips.delegate.doctor.diagnosis.DiagnosisLocal;
import clips.delegate.doctor.prescription.PrescriptionLocal;
import cli_fmw.delegate.DelegateLine2;
import cli_fmw.delegate.cache.Cache;
import cli_fmw.delegate.cache.DelegateExtraDataRO;
import cli_fmw.delegate.cache.DelegateSecondaryCache;
import cli_fmw.delegate.cache.ExtraDataManager;
import cli_fmw.delegate.lists.DataChunkList;
import cli_fmw.delegate.utils.TimeLocal;
import clips.delegate.shedule.reception.SheduleReceptionData;
import cli_fmw.main.DelegatePrintable;
import cli_fmw.report.AlignmentType;
import cli_fmw.report.CombinedReportCreator;
import cli_fmw.report.CombinedReportOptions;
import cli_fmw.report.ExtraField;
import cli_fmw.report.FormReportCreator;
import cli_fmw.report.PageOptions.PageOrentation;
import cli_fmw.report.TableReportOptions;
import cli_fmw.utils.MessageBox;
import cli_fmw.utils.MultiIcon;
import clips.delegate.DEC.DECDisease;
import clips.delegate.contract.ContractLocal;
import clips.delegate.directory.complex.DirectoryCollaboratorFunctions;
import clips.delegate.directory.complex.DirectoryCollaboratorFunctionsItem;
import clips.delegate.directory.ro.DirectoryCollaborator;
import clips.delegate.directory.ro.DirectoryCollaboratorItem;
import clips.delegate.directory.simple.servicingPlace.DirectoryServicingPlace;
import clips.delegate.directory.simple.servicingPlace.DirectoryServicingPlaceItem;
import clips.delegate.directory.simple.receptionType.DirectoryReceptionType;
import clips.delegate.directory.simple.receptionType.DirectoryReceptionTypeItem;
import clips.delegate.doctor.HasDiseaseLocal;
import clips.delegate.doctor.Iconable;
import clips.delegate.doctor.DiseaseLocal;
import clips.delegate.doctor.Signable;
import clips.login.UserInfo;
import beans.directory.service.entity.ServiceGroup;
import beans.service.MoneyTransactionDetails;
import framework.beans.ModificationInfo;
import framework.generic.ClipsServerException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import beans.doctor.contraindication.ContraindicationDetails;
import beans.doctor.diagnosis.DiagnosisDetails;
import beans.doctor.direction.DirectionDetails;
import beans.doctor.prescription.PrescriptionDetails;
import beans.doctor.recommendation.RecommendationDetails;
import beans.doctor.checkup.CheckupDetails;
import beans.doctor.prescriptiondlo.PrescriptionDloDetails;
import cli_fmw.delegate.AuditListener;
import clips.delegate.directory.simple.speciality.DirectorySpeciality;
import clips.delegate.directory.simple.speciality.DirectorySpecialityItem;
import clips.delegate.doctor.prescriptiondlo.PrescriptionDloLocal;
import java.util.HashMap;
import java.util.LinkedHashMap;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import framework.utils.Converter;
import framework.utils.Pair;
import clips.doctor.newEMC.init.generic.ChildrenListStateless;
import clips.doctor.newEMC.init.generic.DelegateNode;
import framework.utils.ROList;
/**
*
* @author Администратор
*/
public class SerRenLocal extends DelegateNode<ServiceRenderBeanRemote, ServiceRenderDetails, DelegateNode<?,?, ?>>
implements Iconable, DelegatePrintable, HasDiseaseLocal, Signable {
private polisCashe polisCache = new polisCashe(getSCM());
private SheduleReceptionCache reception = new SheduleReceptionCache(getEDM());
private DiscountCardCache discountCard = new DiscountCardCache(getEDM());
private DECDisease disease = new DECDisease(this, "случай заболевания, в рамках которого оказана услуга", getAuditListener());
private MoneyTransCache transactionList = new MoneyTransCache(getEDM());
private CheckupCacheList checkupList = new CheckupCacheList(getEDM());
private ContraindicationCacheList contraindications = new ContraindicationCacheList(getEDM());
private PrescriptionCacheList prescriptions = new PrescriptionCacheList(getEDM());
private PrescriptionDloCacheList prescriptionsDlo = new PrescriptionDloCacheList(getEDM());
private DiagnosisCacheList diagnosis = new DiagnosisCacheList(getEDM());
private DirectionCacheList directions = new DirectionCacheList(getEDM());
private RecommendationCacheList recommendations = new RecommendationCacheList(getEDM());
private SerrenCacheList accSerrens = new SerrenCacheList(getEDM());
//статичный мап контрактов по id
private static HashMap<Integer, ContractLocal> contractMap = new HashMap<Integer, ContractLocal>();
ExpenditureList expenditureList = new ExpenditureList(getEDM());
Long transactionSumm; //кеш суммы транзакций
Cache<Boolean> isSerPayed = new Cache<Boolean>(); //кеш оплачена ли услуга полностью
Integer calculatedDiscount; //кеш рассчитанной скидки
private static ImageIcon iconSerren = new ImageIcon(SerRenLocal.class.getResource("/resources/icons/serren.gif"));
private static ImageIcon iconSerrenEnabled = new ImageIcon(SerRenLocal.class.getResource("/resources/icons/serren_enabled.gif"));
private static ImageIcon iconVisit = new ImageIcon(SerRenLocal.class.getResource("/resources/icons/visit.gif"));
private static ImageIcon iconVisitEnabled = new ImageIcon(SerRenLocal.class.getResource("/resources/icons/visit_enabled.gif"));
private static ImageIcon iconDollar = new ImageIcon(SerRenLocal.class.getResource("/resources/icons/dollar.gif"));
private static ImageIcon iconNotRendered = new ImageIcon(SerRenLocal.class.getResource("/resources/icons/notrendered.gif"));
@Override
public int getChildCount() throws ClipsException {
int size = 0;
size += contraindications.getSize();
size += prescriptions.getSize();
size += diagnosis.getSize();
size += directions.getSize();
size += recommendations.getSize();
size += checkupList.getSize();
return size;
}
/**
*
*/
private class MoneyTransCache extends DelegateExtraDataRO<List<MoneyTransactionLocal>> {
public MoneyTransCache(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected List<MoneyTransactionLocal> init() throws Exception {
List<MoneyTransactionLocal> res = new ArrayList<MoneyTransactionLocal>();
for(MoneyTransactionDetails d: getBean().getMoneyTransactionList()) {
res.add(new MoneyTransactionLocal(SerRenLocal.this, d));
}
return res;
}
@Override
protected List<MoneyTransactionLocal> initNew() {
return null;
}
}
/**
* кеш ресепшена
*/
private class SheduleReceptionCache extends DelegateExtraDataRO<SheduleReceptionData> {
public SheduleReceptionCache(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected SheduleReceptionData init() throws Exception {
if(getDetails().receptionDetails == null) {
return null;
}
return new SheduleReceptionData(getPolisData().getClient(getAuditListener()), getDetails().receptionDetails);
}
@Override
protected SheduleReceptionData initNew() {
return null;
}
}
/**
* кеш члена договора
*/
private class polisCashe extends DelegateSecondaryCache<PolisData> {
public polisCashe(SecondaryCacheManager container) throws ClipsException {
super(container, "информацию о полисе");
}
@Override
protected PolisData init() throws Exception {
PolisDetails cmd = getBean().getPolis();
return new PolisData(null, null, cmd);
}
@Override
protected void setPrimary(PolisData data) throws ClipsException {
getDetails().polisID = data.getId();
}
}
/**
* кеш дисконтной карты
*/
private class DiscountCardCache extends DelegateExtraDataRO<DiscountCardLocal> {
public DiscountCardCache(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected DiscountCardLocal init() throws Exception {
DiscountCardDetails details = getBean().getDiscountCard();
if (details != null) {
return new DiscountCardLocal(details, getAuditListener());
}
return null;
}
@Override
protected DiscountCardLocal initNew() {
return null;
}
}
/**
* кеш детей, юзается в дереве эмк
*/
private class CheckupCacheList extends ChildrenListStateless<CheckupLocal, CheckupDetails>{
public CheckupCacheList(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected CheckupLocal createDelegate(CheckupDetails d) throws Exception {
return new CheckupLocal(d, SerRenLocal.this, getAuditListener());
}
@Override
protected List<CheckupDetails> initDetails() throws Exception {
return getBean().getCheckupList();
}
}
/**
* кеш детей, юзается в дереве эмк
*/
private class RecommendationCacheList extends ChildrenListStateless<RecommendationLocal, RecommendationDetails>{
public RecommendationCacheList(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected RecommendationLocal createDelegate(RecommendationDetails d) throws Exception {
return new RecommendationLocal(d, SerRenLocal.this, getAuditListener());
}
@Override
protected List<RecommendationDetails> initDetails() throws Exception {
return getBean().getRecommendationList();
}
}
/**
* кеш детей, юзается в дереве эмк
*/
private class DirectionCacheList extends ChildrenListStateless<DirectionLocal, DirectionDetails>{
public DirectionCacheList(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected DirectionLocal createDelegate(DirectionDetails d) throws Exception {
return new DirectionLocal(d, SerRenLocal.this, getAuditListener());
}
@Override
protected List<DirectionDetails> initDetails() throws Exception {
return getBean().getDirectionList();
}
}
/**
* кеш детей, юзается в дереве эмк
*/
private class ContraindicationCacheList extends ChildrenListStateless<ContraindicationLocal, ContraindicationDetails> {
public ContraindicationCacheList(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected ContraindicationLocal createDelegate(ContraindicationDetails d) throws Exception {
return new ContraindicationLocal(d, SerRenLocal.this, getAuditListener());
}
@Override
protected List<ContraindicationDetails> initDetails() throws Exception {
return getBean().getContraindicationList();
}
}
/**
* кеш детей, юзается в дереве эмк
*/
private class PrescriptionCacheList extends ChildrenListStateless<PrescriptionLocal, PrescriptionDetails> {
public PrescriptionCacheList(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected PrescriptionLocal createDelegate(PrescriptionDetails d) throws Exception {
return new PrescriptionLocal(d, SerRenLocal.this, getAuditListener());
}
@Override
protected List<PrescriptionDetails> initDetails() throws Exception {
return getBean().getPrescriptionList();
}
}
/**
* кеш льготных рецептов, юзается в дереве эмк
*/
private class PrescriptionDloCacheList extends ChildrenListStateless<PrescriptionDloLocal, PrescriptionDloDetails> {
public PrescriptionDloCacheList(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected PrescriptionDloLocal createDelegate(PrescriptionDloDetails d) throws Exception {
return new PrescriptionDloLocal(d, SerRenLocal.this, getAuditListener());
}
@Override
protected List<PrescriptionDloDetails> initDetails() throws Exception {
return getBean().getPrescriptionDloList();
}
}
/**
* кеш детей, юзается в дереве эмк
*/
private class DiagnosisCacheList extends ChildrenListStateless<DiagnosisLocal, DiagnosisDetails> {
public DiagnosisCacheList(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected DiagnosisLocal createDelegate(DiagnosisDetails d) throws Exception {
return new DiagnosisLocal(d, SerRenLocal.this, getAuditListener());
}
@Override
protected List<DiagnosisDetails> initDetails() throws Exception {
return getBean().getDiagnosisList();
}
}
/**
*
*/
private class SerrenCacheList extends DelegateExtraDataRO<List<SerRenLocal>> {
public SerrenCacheList(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected List<SerRenLocal> init() throws Exception {
List<SerRenLocal> res = new ArrayList<SerRenLocal>();
for(ServiceRenderDetails d: getBean().getAccomplichedSerrenList()) {
res.add(new SerRenLocal(new DiseaseLocal(getDiseaseLocal().getEmcLocal(), d.diseaseID, getAuditListener()), d, getAuditListener()));
}
return res;
}
@Override
protected List<SerRenLocal> initNew() {
return null;
}
}
/**
*
* @param id
*/
public SerRenLocal(int id, AuditListener al) throws ClipsException {
super(id, al);
}
public SerRenLocal(int id, DiseaseLocal disease, AuditListener al) throws ClipsException {
super(id, al);
this.disease.initBy(disease);
}
/**
* Позволяет создать услугу с известным заболеванием
* @param disease
* @param details
* @throws ClipsException
*/
public SerRenLocal(DiseaseLocal disease, ServiceRenderDetails details, AuditListener al) throws ClipsException {
super(details, al);
this.disease.initBy(disease);
}
/**
* Позволяет создать услугу с неизвестным заболеванием
* @param details
* @throws ClipsException
*/
public SerRenLocal(ServiceRenderDetails details, AuditListener al) throws ClipsException {
super(details, al);
}
public void setUet(int uet) throws ClipsException {
getDetails().uet = uet;
}
public int getUet() throws ClipsException {
return getDetails().uet;
}
@Override
protected ServiceRenderDetails getNewDetails() {
return new ServiceRenderDetails();
}
public boolean canReadExpenditure() throws ClipsException {
return hasRight(ServiceRenderBean.COMMAND_READ);
}
public boolean canReadMedicalData() throws ClipsException {
return hasRight(ServiceRenderBean.COMMAND_READ_MEDICAL_DATA);
}
/**
* Возвращает итератор расхода mатериалов
* @return
* @throws ClipsException
*/
public SelectorEditable<ExpenditureItemData> getExpenditureList() throws ClipsException {
return expenditureList.selector();
}
/**
* По какому полису была проведена оплата
* @return
* @throws ClipsException
*/
public PolisData getPolisData() throws ClipsException {
return polisCache.get();
}
/**
* По какому полису была проведена оплата
* @param data
* @throws ClipsException
*/
public void setPolisData(PolisData data) throws ClipsException {
polisCache.set(data);
}
/**
* дата назначения услуги
* @return
* @throws ClipsException
*/
public Date getSerDate() throws ClipsException {
return getDetails().date;
}
/**
* дата назначения услуги
* @param serDate
* @throws ClipsException
*/
public void setSerDate(Date serDate) throws ClipsException {
getDetails().date = serDate;
fireContentStateEvent();
}
/**
* Услуга оказана
* @return
* @throws ClipsException
*/
public boolean isRendered() throws ClipsException {
return getDetails().functionsID != 0 && getDetails().renderDate != null;
}
/**
* Оказать услугу
* @param functions исполняемая обязанность
* @throws cli_fmw.main.ClipsException
*/
public void setRendered(DirectoryCollaboratorFunctionsItem functions) throws ClipsException {
if (UserInfo.get().getCollaborator().hasReceptionType(functions.getReceptionType())
|| UserInfo.get().isSuperUser()){
getDetails().functionsID = functions.getID();
getDetails().renderDate = TimeLocal.getCurrentTime().getTime();
isSerPayed.clearCache();
fireContentStateEvent();
}else{
throw new ClipsException("Текущий пользователь не имеет типа приема \'" + functions.getReceptionType().getTitle() + "\'");
}
}
/**
* Дата оказания услуги
* @return
* @throws ClipsException
*/
public Date getSerRenderDate() throws ClipsException {
return getDetails().renderDate;
}
/**
* Дата оказания услуги
* @param serRenderDate
* @throws ClipsException
*/
public void setSerRenderDate(Date serRenderDate) throws ClipsException {
getDetails().renderDate = serRenderDate;
fireContentStateEvent();
}
public SheduleReceptionData getReception() throws ClipsException {
return reception.get();
}
public void setReception(SheduleReceptionData reception) throws ClipsException {
this.reception.set(reception);
fireContentStateEvent();
}
/**
* Скидка с которой должна быть оказана услуга
* расчитывается в бине, в делегате только кеш
* @return 0-100
*/
public int getCalculatedDiscount() throws ClipsException {
if (calculatedDiscount == null) {
try {
calculatedDiscount = getBean().getCalculatedDiscount();
} catch (Exception ex) {
clearBean();
throw new ClipsException("Не удалось получить значение скидки", ex);
}
}
return calculatedDiscount;
}
/**
* Скидка с которой должна быть оказана услуга
* запрещено к использованию, т.к. все расссчеты делаются на стороне сервера и при изменении этого
* значения устареют данные о рассчитанной скидке и о том, полностью ли оплачена услуга.
* Заново рассчитать эти устаревшие данные в бине невозможно, так как в нем еще нет обновленной информации
* @param serDiscount
*/
@Deprecated
public void setSerDiscount(Integer serDiscount) throws ClipsException {
getDetails().discount = serDiscount;
}
/**
* Оплачена ли услуга полностью
* @return
*/
public boolean isSerPayed() throws ClipsException {
if (!isSerPayed.inCache()) {
boolean hasRight = hasRight(ServiceRenderBean.COMMAND_READ_SERVICE_RENDER_TRANSACTION_SUMM);
if (!hasRight) {
isSerPayed.set(true);
return isSerPayed.get();
}
try {
isSerPayed.set(getBean().isSerPayed());
} catch (Exception ex) {
isSerPayed.set(null);
clearBean();
throw new ClipsException("Ошибка при получении информации об услуге", ex);
}
}
if (isSerPayed.get() != null) {
return isSerPayed.get();
} else {
throw new ClipsException("Ошибка при получении информации об услуге");
}
}
/**
* Отмененных услуг на клиенте быть не должно впринципе
* @return
*/
@Deprecated
public boolean isSerCanceled() throws ClipsException {
return getDetails().cancelled;
}
/**
* Отмененных услуг на клиенте быть не должно впринципе
* @param serCanceled
* @deprecated
*/
@Deprecated
public void setSerCanceled(boolean serCanceled) throws ClipsException {
getDetails().cancelled = serCanceled;
}
/**
* Повторы оказания услуги
* @return
*/
public int getSerRepeat() throws ClipsException {
return getDetails().repeat;
}
/**
* Повторы оказания услуги (при первом оказании повтор 0)
* @param serRepeat
* @throws ClipsException
*/
public void setSerRepeat(int serRepeat) throws ClipsException {
getDetails().repeat = serRepeat;
}
public DirectoryServicingPlaceItem getServicingPlace() throws ClipsException{
DirectoryServicingPlace place = DirectoryLocator.getDirectory(DirectoryServicingPlace.class);
return place.getItemFromID(getDetails().servPlaceID);
}
public void setServicingPlace(DirectoryServicingPlaceItem place) throws ClipsException{
getDetails().servPlaceID = place.getID();
fireContentStateEvent();
}
/**
* Врач, обслуживший
* @return
* @throws ClipsException
*/
public DirectoryCollaboratorFunctionsItem getCollaboratorFunctions() throws ClipsException {
if (getDetails().functionsID != 0) {
DirectoryCollaboratorFunctions dcf = DirectoryLocator.getDirectory(DirectoryCollaboratorFunctions.class);
return dcf.getItemFromID(getDetails().functionsID);
} else {
return null;
}
}
/**
* Врач, обслуживший
* @param collaborator
* @throws ClipsException
*/
public void setCollaboratorFunctions(DirectoryCollaboratorFunctionsItem collabFunctions) throws ClipsException {
getDetails().functionsID = collabFunctions.getID();
fireContentStateEvent();
}
/**
* Кем назначена
* @return
* @throws ClipsException
*/
public DirectoryCollaboratorItem getSerRenDirector() throws ClipsException {
DirectoryCollaborator dir = DirectoryLocator.getDirectory(DirectoryCollaborator.class, false);
return dir.getItemFromID(getDetails().directorID);
}
/**
* Кем назначена
* @param serRenDirector
* @throws ClipsException
*/
public void setSerRenDirector(DirectoryCollaboratorItem serRenDirector) throws ClipsException {
getDetails().directorID = serRenDirector.getID();
fireContentStateEvent();
}
/**
* Тип услуги
* @return
* @throws ClipsException
*/
public DirectoryServiceItem getService() throws ClipsException {
DirectoryService services = DirectoryLocator.getDirectory(DirectoryService.class, false);
return services.getItemFromID(getDetails().serviceID);
}
/**
* Тип услуги
* @param service
* @throws ClipsException
*/
@Deprecated
public void setService(DirectoryServiceItem service) throws ClipsException {
getDetails().serviceID = service.getID();
fireContentStateEvent();
}
/**
* Привязка к заболеванию
* @return
* @throws ClipsException
*/
@Override
public DiseaseLocal getDiseaseLocal() throws ClipsException {
return disease.get();
}
/**
* Привязка к заболеванию
* @param disease
* @throws ClipsException
*/
public void setDiseaseLocal(DiseaseLocal disease) throws ClipsException {
this.disease.set(disease);
fireContentStateEvent();
}
/**
* Дисконтная карта
* @return
* @throws ClipsException
*/
public DiscountCardLocal getDiscCard() throws ClipsException {
return discountCard.get();
}
/**
* ID Пакета услуг
* @return
* @throws ClipsException
*/
public int getPacketServiceID() throws ClipsException {
return getDetails().packetServiceID;
}
/**
* Пакет услуг
* @param packetService
* будет удалена ибо нефиг перекидывать серрены из пакета в пакет
*/
@Deprecated
public void setPacketService() {
// this.packetService.set(packetService);
}
/**
* Список транзакций
* @return
* @throws ClipsException
*/
public List<MoneyTransactionLocal> getTransactionList()
throws ClipsException {
return transactionList.get();
}
/**
* Сумма транзакций
* @return
* @throws ClipsException
*/
public long getTransactionSumm() throws ClipsException {
if (transactionSumm == null) {
if (hasRight(ServiceRenderBean.COMMAND_READ_SERVICE_RENDER_TRANSACTION_SUMM)){
try {
transactionSumm = getBean().getMoneyTransactionSumm();
} catch (Exception ex) {
clearBean();
throw new ClipsException("Не удалось загрузить сумму транзакций",ex);
}
}else{
throw new ClipsException("Не удалось загрузить сумму транзакций:\n Нет права \'Чтение суммарных данных по оплате услуги\'");
}
}
return transactionSumm;
}
@Override
public String toString() {
try {
String res = "";
DirectorySpecialityItem spec = null;
if (getSpeciality() != null && getSpeciality().getID() != 0) {
spec = getSpeciality();
}
if (getCollaboratorFunctions() != null){
DirectoryReceptionTypeItem recType = getCollaboratorFunctions().getReceptionType();
if (isVisit() && recType.getExtKey() != null) {
res += "(" + recType.getExtKey() + getService().getCode() + ")";
}
if (getCollaboratorFunctions().getSpeciality() != null
&& getCollaboratorFunctions().getSpeciality().getID() != 0) {
spec = getCollaboratorFunctions().getSpeciality();
}
}
res = res + getService().getTitle();
if (spec != null) {
res = res + ", " + spec;
}
return res;
} catch (ClipsException ex) {
MessageBox.showException(ex);
return super.toString();
}
}
public static void clearContractMap() {
contractMap.clear();
}
/**
* Запрос цены на данную услугу по данному договору
* Если услуга не найдена в списке, вернет null
* @return
* @throws ClipsException
*/
public ServisePriceData getContractService() throws ClipsException {
//чтобы не создавались копии контрактов, загнал их в мап
//в течении сеанса цены на услуги не будут обновляться
int contractID = getPolisData().getDetails().contractID;
ContractLocal contract;
if (contractMap.containsKey(contractID)) {
contract = contractMap.get(contractID);
} else {
contract = getPolisData().getContract();
contractMap.put(contractID, contract);
}
DirectoryServiceItem service = getService();
ServisePriceData contractService = null;
DirectoryReceptionTypeItem nullItem = DirectoryLocator.getDirectory(DirectoryReceptionType.class).getNullItem();
DirectoryReceptionTypeItem recType = nullItem;
if (getCollaboratorFunctions() != null){
recType = getCollaboratorFunctions().getReceptionType();
}
contractService = contract.getContractService(new Pair<DirectoryServiceItem, DirectoryReceptionTypeItem>(service, recType));
if (contractService == null){
contractService = contract.getContractService(new Pair<DirectoryServiceItem, DirectoryReceptionTypeItem>(service, nullItem));
}
return contractService;
// return getPolis().getContract().getContractService(getService());
}
public List<ServiceRenderDetails> getPacketSerrenList(boolean returnThis) throws ClipsException{
List<ServiceRenderDetails> set;
try {
set = getBean().getPacketSerrenList();
} catch (Exception ex) {
clearBean();
throw new ClipsException("Ошибка при получении списка услуг пакета", ex);
}
if (! returnThis){
set.remove(getDetails());
}
return set;
}
public boolean hasReferencedSerRen() throws ClipsException {
return getDetails().referencedID != 0;
}
//услуга, к которой привязана сия
public SerRenLocal getReferencedSerRen() throws ClipsException {
return getDetails().referencedID == 0 ? null : new SerRenLocal(getDetails().referencedID, getDiseaseLocal(), getAuditListener());
}
public void setReferencedSerRen(SerRenLocal serRenLocal) throws ClipsException {
getDetails().referencedID = serRenLocal.getID();
fireContentStateEvent();
}
public DirectorySpecialityItem getSpeciality() throws ClipsException {
DirectorySpeciality dir = DirectoryLocator.getDirectory(DirectorySpeciality.class);
return dir.getItemFromID(getDetails().specialityID);
}
@Deprecated
public void setReceptionType(DirectoryReceptionTypeItem item) throws ClipsException {
throw new UnsupportedOperationException("Запрещено на клиенте");
}
/**
* @return список услуг привязанных к данной
* @throws cli_fmw.main.ClipsException
*/
public List<SerRenLocal> getAccSerrens() throws ClipsException {
return accSerrens.get();
}
@Override
protected void addChildImpl(DelegateNode child) throws ClipsException {
if (child instanceof ContraindicationLocal) {
contraindications.get().add((ContraindicationLocal) child);
} else if (child instanceof PrescriptionLocal) {
prescriptions.get().add((PrescriptionLocal) child);
} else if (child instanceof DiagnosisLocal) {
diagnosis.get().add((DiagnosisLocal) child);
} else if (child instanceof DirectionLocal) {
directions.get().add((DirectionLocal) child);
} else if (child instanceof RecommendationLocal) {
recommendations.get().add((RecommendationLocal) child);
} else if (child instanceof CheckupLocal) {
checkupList.get().add((CheckupLocal) child);
} else if (child instanceof PrescriptionDloLocal) {
prescriptionsDlo.get().add((PrescriptionDloLocal) child);
}
}
@Override
protected void removeChildImpl(DelegateNode child) throws ClipsException {
if(child instanceof ContraindicationLocal) {
contraindications.get().remove((ContraindicationLocal) child);
} else if(child instanceof PrescriptionLocal) {
prescriptions.get().remove((PrescriptionLocal) child);
} else if(child instanceof DiagnosisLocal) {
diagnosis.get().remove((DiagnosisLocal) child);
} else if(child instanceof DirectionLocal) {
directions.get().remove((DirectionLocal) child);
} else if(child instanceof RecommendationLocal) {
recommendations.get().remove((RecommendationLocal) child);
} else if(child instanceof CheckupLocal) {
checkupList.get().remove((CheckupLocal) child);
} else if(child instanceof PrescriptionDloLocal) {
prescriptionsDlo.get().remove((PrescriptionDloLocal) child);
} else {
throw new IllegalArgumentException("Not existent child");
}
}
/**
* Возвращает список делегатов - действий доктора, которые были созданы в рамках данной услуги
* @return
* @throws ClipsException
*/
@Override
public ROList<DelegateNode<?,?,?>> getChildren() throws ClipsException {
List<DelegateNode<?,?,?>> list = new ArrayList<DelegateNode<?,?,?>>();
list.addAll(contraindications.get());
list.addAll(prescriptions.get());
list.addAll(diagnosis.get());
list.addAll(directions.get());
list.addAll(recommendations.get());
list.addAll(checkupList.get());
list.addAll(prescriptionsDlo.get());
return new ROList<DelegateNode<?, ?, ?>>(list);
}
public CheckupLocal getAnalysis() throws ClipsException{
for (CheckupLocal cl : checkupList.get()){
if (cl.getType().isAnalyse()){
return cl;
}
}
return null;
}
public List<DiagnosisLocal> getDiagnosisList() throws ClipsException{
return new ArrayList<DiagnosisLocal>(diagnosis.get());
}
public boolean isVisit() throws ClipsException {
return getService().getGroup().getID() == ServiceGroup.SERVICE_GROUP_VISIT;
}
/**
* Рекомендуется использовать еэтот метод для удаления услуги *
* @param forceBreak только при выставленном параметре услуга удалится из пакета
* @throws cli_fmw.main.ClipsException
* Пётр: поржал, поплакал. Сделайте что нибудь с этим методом, пожалуйста...
*/
public void removeAndBreakPacket() throws ClipsException {
try {
ModificationInfo info = getBean().removeAndBreakPacket();
auditDetailsList.addAll(info.getAudit());
} catch (Exception ex) {
try {
clearBean();
ModificationInfo info = getBean().removeAndBreakPacket();
auditDetailsList.addAll(info.getAudit());
} catch (Exception ex1) {
clearBean();
throw new ClipsException("Не удалось удалить объект 'Назначенная услуга'", ex1);
}
}finally{
fireAuditEvent();
}
}
@Override
public Icon getIcon() {
MultiIcon icon = null;
try {
boolean editable = hasRight(ServiceRenderBean.COMMAND_MODIFY);
if (editable) {
if (isVisit()) {
icon = new MultiIcon(iconVisitEnabled);
} else {
icon = new MultiIcon(iconSerrenEnabled);
}
} else {
if (isVisit()) {
icon = new MultiIcon(iconVisit);
} else {
icon = new MultiIcon(iconSerren);
}
}
if (!isRendered()) {
icon.addIcon(iconNotRendered);
}
if (getPolisData().getContract().getType() != Contract.TYPE_OMI
&& !isSerPayed()) {
icon.addIcon(iconDollar);
}
return icon;
} catch (ClipsException ex) {
if (icon == null) {
return new MultiIcon(iconSerren);
} else {
return icon;
}
}
}
@Override
protected String getBeanName() {
return "ServiceRenderBean";
}
class ExpenditureList extends DataChunkList<ExpenditureItemData> {
public ExpenditureList(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected void deleteDB(ExpenditureItemData data) throws Exception {
getBean().removeExpenditure(data.getDetailsCopy().getId());
}
@Override
protected int saveDB(ExpenditureItemData data) throws Exception {
ModificationInfo info = getBean().setExpenditure(data.getDetailsCopy());
auditDetailsList.addAll(info.getAudit());
fireAuditEvent();
return info.getId();
}
@Override
protected void loadDB() throws Exception {
for (ExpenditureDetails d : getBean().getExpenditureList()) {
initByDetails(new ExpenditureItemData(d));
}
}
}
@Override
public void print(CombinedReportCreator cCreator) throws ClipsException {
HashMap<String, Object> data = new LinkedHashMap<String, Object>();
String title = "Услуга: " + getService().toString();
ExtraField extraField;
//назначена
DirectoryCollaboratorItem director = getSerRenDirector();
String toPut = director.toString() + " [" + Converter.dateToString(getSerDate()) + "]";
extraField = new ExtraField(toPut, "Назначена: ", AlignmentType.dataInOneColoumnByLeft);
data.put("assigned", extraField);
//оказана
toPut = "";
if (isRendered()) {
DirectoryCollaboratorItem collaborator = getCollaboratorFunctions().getCollaborator();
toPut = collaborator.toString() + " [" + Converter.dateToString(getSerRenderDate()) + "]";
} else {
toPut = "не оказана";
}
extraField = new ExtraField(toPut, "Оказана: ", AlignmentType.dataInOneColoumnByLeft);
data.put("directed", extraField);
CombinedReportCreator parCreator = cCreator.createCombinedReporter(getClass(), 1);
CombinedReportOptions ops = new CombinedReportOptions();
ops.setPageA5();
ops.setOrentation(PageOrentation.horizontal);
ops.leftMargin = 0;
ops.rightMargin = 0;
ops.bottomMargin = 0;
ops.topMargin = 0;
parCreator.setUpReport(null, ops, null);
FormReportCreator creator = parCreator.createFormReporter(getClass(), 2);
TableReportOptions opts = new TableReportOptions();
opts.bottomMargin = 0;
opts.topMargin = 0;
creator.createReport(title, opts, data.entrySet(), null);
creator.finish();
for (DelegateLine2 child : getChildren()) {
if (child instanceof DelegatePrintable) {
((DelegatePrintable)child).print(parCreator);
}
}
parCreator.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 (getCollaboratorFunctions() != null) {
coll = getCollaboratorFunctions().getTitle();
} else {
coll = getSerRenDirector().getTitle();
}
String s = "Подписано " + Converter.dateToString(getSerDate())
+ " - " + coll;
if (isSignCorrect() ) {
return s;
} else {
return "Подпись не соответствует данным!";
}
//END STUB
}
/**
*
* @return null если может оказать или причину по которой не может
*/
public String canBeRenderedByCurrentCollaborator() throws ClipsException{
try {
ServiceRenderBeanRemote bean = getBean();
return bean.canRenderService();
} catch (ClipsServerException ex) {
clearBean();
throw new ClipsException("Невозможно получить сведения о доступности возможности оказания услуги", ex);
}
}
}