/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package clips.delegate.service.mes;
import beans.service.mes.MedicEconomicStandartBean;
import beans.service.mes.MedicEconomicStandartBeanRemote;
import cli_fmw.delegate.directory.Directory;
import cli_fmw.delegate.directory.DirectoryItemRO;
import cli_fmw.delegate.directory.complex.DirectoryLocator;
import clips.delegate.directory.complex.DirectoryMKB10;
import clips.delegate.directory.complex.DirectoryMKB10Item;
import cli_fmw.delegate.DelegateLine2;
import cli_fmw.delegate.cache.DelegateSecondaryCache;
import cli_fmw.main.ClipsException;
import clips.delegate.directory.complex.DirectoryMESClass;
import clips.delegate.directory.complex.DirectoryMESClassItem;
import clips.delegate.directory.filtered.DirectoryService;
import clips.delegate.directory.filtered.DirectoryServiceItem;
import clips.delegate.directory.simple.mes.DirectoryMESTarget;
import clips.delegate.directory.simple.mes.DirectoryMESTargetItem;
import clips.delegate.directory.simple.receptionType.DirectoryReceptionType;
import clips.delegate.directory.simple.receptionType.DirectoryReceptionTypeItem;
import beans.service.mes.entity.MedicEconomicStandartDetail;
import cli_fmw.delegate.AuditListener;
import java.util.HashSet;
import java.util.Set;
/**
*
* @author finder
*/
public class MedicEconomicStandartLocal extends DelegateLine2<MedicEconomicStandartBeanRemote, MedicEconomicStandartDetail> {
DelegateSecondaryCache<HashSet<DirectoryMKB10Item>> mkb10Cache
= new DelegateSecondaryCache<HashSet<DirectoryMKB10Item>>(getSCM(), "диагноз по МКБ-10") {
@Override
protected void setPrimary(HashSet<DirectoryMKB10Item> type) throws ClipsException {
getDetails().receptionTypes = saveDir(type);
}
@Override
protected HashSet<DirectoryMKB10Item> init() throws Exception {
return loadDir(getDetails().receptionTypes, DirectoryLocator.getDirectory(DirectoryMKB10.class, false));
}
};
DelegateSecondaryCache<HashSet<DirectoryServiceItem>>serviceCache
= new DelegateSecondaryCache<HashSet<DirectoryServiceItem>>(getSCM(), "список типов услуг") {
@Override
protected void setPrimary(HashSet<DirectoryServiceItem> type) throws ClipsException {
getDetails().receptionTypes = saveDir(type);
}
@Override
protected HashSet<DirectoryServiceItem> init() throws Exception {
return loadDir(getDetails().receptionTypes, DirectoryLocator.getDirectory(DirectoryService.class));
}
};
DelegateSecondaryCache<HashSet<DirectoryReceptionTypeItem>> recTypeCache
= new DelegateSecondaryCache<HashSet<DirectoryReceptionTypeItem>>(getSCM(), "список типов приемов") {
@Override
protected void setPrimary(HashSet<DirectoryReceptionTypeItem> type) throws ClipsException {
getDetails().receptionTypes = saveDir(type);
}
@Override
protected HashSet<DirectoryReceptionTypeItem> init() throws Exception {
return loadDir(getDetails().receptionTypes, DirectoryLocator.getDirectory(DirectoryReceptionType.class));
}
};
private <T extends DirectoryItemRO<?>> HashSet<T> loadDir(Set<Integer> ids, Directory<T> dir) throws ClipsException{
HashSet<T> target = new HashSet<T>();
for (Integer id : ids) {
if (id != null){
target.add(dir.getItemFromID(id));
}
else {
target.add(dir.getItemFromID(0));
}
}
return target;
}
private Set<Integer> saveDir(Set<? extends DirectoryItemRO<?>> items){
HashSet<Integer> target = new HashSet<Integer>();
for (DirectoryItemRO<?> directoryItemRO : items) {
target.add(directoryItemRO.getID());
}
return target;
}
public MedicEconomicStandartLocal(MedicEconomicStandartDetail d, AuditListener al) throws ClipsException{
super(d, al);
}
public MedicEconomicStandartLocal(int initializedID, AuditListener al) throws ClipsException{
super(initializedID, al);
}
public MedicEconomicStandartLocal(AuditListener al) throws ClipsException {
super(al);
}
@Override
protected MedicEconomicStandartDetail getNewDetails() {
return new MedicEconomicStandartDetail();
}
@Override
protected String getBeanName() {
return MedicEconomicStandartBean.class.getSimpleName();
}
public String getCode() throws ClipsException {
return getDetails().code;
}
public void setCode(String code) throws ClipsException {
getDetails().code = code;
fireContentStateEvent();
}
public Integer getComplexityOperations() throws ClipsException {
return getDetails().complexityOperations;
}
public void setComplexityOperations(Integer mesComplexityOperations) throws ClipsException {
getDetails().complexityOperations = mesComplexityOperations;
fireContentStateEvent();
}
public Integer getComplexitySupervision() throws ClipsException {
return getDetails().complexitySupervision;
}
public void setComplexitySupervision(Integer mesComplexitySupervision) throws ClipsException {
getDetails().complexitySupervision = mesComplexitySupervision;
fireContentStateEvent();
}
public String getCriteriaOfQuality() throws ClipsException {
return getDetails().criteriaOfQuality;
}
public void setCriteriaOfQuality(String criteriaOfQuality) throws ClipsException {
getDetails().criteriaOfQuality = criteriaOfQuality;
fireContentStateEvent();
}
public String getDiseaseName() throws ClipsException {
return getDetails().diseaseName;
}
public void setDiseaseName(String mesDiseaseName) throws ClipsException {
getDetails().diseaseName = mesDiseaseName;
fireContentStateEvent();
}
public Integer getNormalDuration() throws ClipsException {
return getDetails().normalDuration;
}
public void setNormalDuration(Integer mesNormalDuration) throws ClipsException {
getDetails().normalDuration = mesNormalDuration;
fireContentStateEvent();
}
public int getTariff() throws ClipsException {
return getDetails().tariff;
}
public void setTariff(int mesTariff) throws ClipsException {
getDetails().tariff = mesTariff;
fireContentStateEvent();
}
public String getSizeOfCure() throws ClipsException {
return getDetails().sizeOfCure;
}
public void setSizeOfCure(String sizeOfCure) throws ClipsException {
getDetails().sizeOfCure = sizeOfCure;
fireContentStateEvent();
}
public DirectoryMESClassItem getMesType() throws ClipsException {
return DirectoryLocator.getDirectory(DirectoryMESClass.class).getItemFromID(getDetails().mesClassId);
}
public void setMesType(DirectoryMESClassItem type) throws ClipsException {
getDetails().mesClassId = type.getID();
fireContentStateEvent();
}
public DirectoryMESTargetItem getMesTargets() throws ClipsException {
return DirectoryLocator.getDirectory(DirectoryMESTarget.class).getItemFromID(getDetails().targetsId);
}
public void setMesTargets(DirectoryMESTargetItem targets) throws ClipsException {
getDetails().targetsId = targets.getID();
fireContentStateEvent();
}
@SuppressWarnings("unchecked")
public Set<DirectoryMKB10Item> getMkb10() throws ClipsException {
return new HashSet<DirectoryMKB10Item>(mkb10Cache.get());
}
public void setMkb10(Set<DirectoryMKB10Item> mkb10) throws ClipsException {
mkb10Cache.set(new HashSet<DirectoryMKB10Item>(mkb10));
}
@SuppressWarnings("unchecked")
public Set<DirectoryServiceItem> getService() throws ClipsException {
return new HashSet<DirectoryServiceItem>(serviceCache.get());
}
public void setService(Set<DirectoryServiceItem> service) throws ClipsException {
serviceCache.set(new HashSet<DirectoryServiceItem>(service));
}
@SuppressWarnings("unchecked")
public Set<DirectoryReceptionTypeItem> getReceptionType() throws ClipsException {
return new HashSet<DirectoryReceptionTypeItem>(recTypeCache.get());
}
public void setReceptionType(Set<DirectoryReceptionTypeItem> recType) throws ClipsException {
recTypeCache.set(new HashSet<DirectoryReceptionTypeItem>(recType));
}
}