/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package clips.delegate.doctor.certificate.tag.certTags;
import cli_fmw.delegate.report.ReportParam;
import cli_fmw.main.ClipsException;
import cli_fmw.utils.Selector;
import clips.delegate.client.CollaboratorFunctionsChunk;
import clips.delegate.client.CollaboratorLocal;
import clips.delegate.directory.simple.dvr.DirectoryDvrItem;
import clips.delegate.doctor.DiseaseLocal;
import clips.delegate.doctor.certificate.CertificateLocal;
import clips.delegate.doctor.certificate.tag.TagToClass;
import clips.delegate.doctor.certificate.tag.interfaces.TypeSelectable;
import framework.utils.PairIntStr;
/**
*
* @author lacoste
*/
@TagToClass(tagName="collab_appointment", title="Должность медицинского работника, направившего больного")
public class CertTagCollabAppointment extends TypeSelectable {
int defaultid;
public CertTagCollabAppointment() throws ClipsException {
}
public CertTagCollabAppointment(CertificateLocal certificateLocal, ReportParam reportParam, DiseaseLocal diseaseLocal) throws ClipsException {
super(certificateLocal, reportParam, diseaseLocal);
if (certificateLocal.isNewlyCreated()) {
setItem(defaultid);
}
}
@Override
public void fillItems() throws ClipsException {
if (certificateLocal == null) {
throw new ClipsException();
}
CollaboratorLocal collab = new CollaboratorLocal(certificateLocal.getCollaborator().getID(), null);//NULL AL
Selector<CollaboratorFunctionsChunk> funcList = collab.getFunctions();
for (int i = 0; i < funcList.size(); i++) {
CollaboratorFunctionsChunk function = funcList.get(i);
if (defaultid == 0) {
defaultid = function.getId();
}
DirectoryDvrItem item = function.getDvr();
if (item != null) {
PairIntStr pair = new PairIntStr(item.getID(), item.getTitle());
allItems.add(pair);
}
}
}
@Override
public boolean isEditable() {
return true;
}
@Override
public String getValue() throws ClipsException {
return getText();
}
}