boolean rendered = serRen.isRendered();
CheckupXMLData data = getCheckupXMLData();
boolean isAnalysys = data.getCheckupType().isAnalyse();
SegmentedTableReporter analyseReporter = cCreator.createAnalyseReporter(getClass());
//название анализа
String title;
if (isAnalysys) {
title = "Анализ: ";
}
else {
title = "Осмотр: ";
}
analyseReporter.setTitle(title + data.getCheckupType().getTitle());
//Фиелды до таблицы
String fieldName;
String fieldValue;
ExtraField extraField;
ClientLocal client = serRen.getPolisData().getClient(getAuditListener());
fieldName = "Пациент: ";
fieldValue = client.toString();
if (isAnalysys) {
fieldValue += " (" + Converter.dateToString(client.getBorn()) + ")";
}
extraField = new ExtraField(fieldValue, fieldName, AlignmentType.left);
analyseReporter.addField(extraField, false);
if (isAnalysys) {
fieldName = "Направил: ";
fieldValue = serRen.getSerRenDirector().toString();
fieldValue += " (" + Converter.dateToString(serRen.getSerDate()) + ")";
extraField = new ExtraField(fieldValue, fieldName, AlignmentType.left);
analyseReporter.addField(extraField, false);
if (rendered) {
fieldName = "Дата забора биоматериала: ";
fieldValue = Converter.dateToString(getDate());
extraField = new ExtraField(fieldValue, fieldName, AlignmentType.left);
analyseReporter.addField(extraField, false);
}
}
else {
ArrayList<FieldForXML> preField = data.getPreFieldList();
for(int i = 0; i < preField.size(); i++) {
fieldName = preField.get(i).title + ": ";
fieldValue = data.getField(preField.get(i).id);
if (fieldValue == null) {
fieldValue = "";
}
extraField = new ExtraField(fieldValue, fieldName, AlignmentType.dataInOneColoumnByLeft);
analyseReporter.addField(extraField, false);
}
}
ArrayList<String> probeList = data.getProbeList();
if (!probeList.isEmpty()) {
//добавляем заголовок таблицы
List<String> header = new ArrayList<String>();
header.add("Методика");
ArrayList<String> valueList = data.getProbeValueList();
for (int i = 0; i < valueList.size(); i++) {
String titleStr = data.getProbeValueTitle(valueList.get(i));
header.add(titleStr);
}
header.add("Описание");
analyseReporter.setHeader(header);
//добавляем строки таблицы
List<String> row;
for (int i = 0; i < probeList.size(); i++) {
row = new ArrayList<String>();
if (probeList.get(i).startsWith("separator")) {
String separator = data.getProbeTitle(probeList.get(i)).replace("separator ", "");
analyseReporter.addSeparator(separator);
}
else {
row.add(data.getProbeTitle(probeList.get(i)));
for (int j = 0; j < valueList.size(); j++) {
Object value = data.getProbeValue(probeList.get(i), valueList.get(j));
String metric = data.getProbeValueMetric(probeList.get(i), valueList.get(j));
String valueMetric = ( value == null ? "" : value.toString() + " " + (metric == null ? "" : metric));
row.add(valueMetric);
}
String description = data.getProbeDescription(probeList.get(i));
row.add(description);
analyseReporter.addRow(row);
}
}
}
//Фиелды после таблицы
if (isAnalysys) {
if (rendered) {
fieldName = "Анализ провел(дата исследования): ";
fieldValue = serRen.getCollaboratorFunctions() == null
? "" : serRen.getCollaboratorFunctions().getCollaborator().toString();
fieldValue += serRen.getSerRenderDate() == null
? "" : " (" + Converter.dateToString(serRen.getSerRenderDate()) + ")";
}
else {
fieldName = "Рекомендации: ";
fieldValue = serRen.getService().getDescription();
}
extraField = new ExtraField(fieldValue, fieldName, AlignmentType.dataInOneColoumnByLeft);
analyseReporter.addField(extraField, true);
}
else {
ArrayList<FieldForXML> postField = data.getPostFieldList();
for(int i = 0; i < postField.size(); i++) {
fieldName = postField.get(i).title + ": ";
fieldValue = data.getField(postField.get(i).id);
if (fieldValue == null) {
fieldValue = "";
}
extraField = new ExtraField(fieldValue, fieldName, AlignmentType.dataInOneColoumnByLeft);
analyseReporter.addField(extraField, true);
}
DirectoryCollaboratorItem collab = serRen.getSerRenDirector();
fieldName = "Врач: ";
fieldValue = collab.getTitle();
extraField = new ExtraField(fieldValue, fieldName, AlignmentType.left);
analyseReporter.addField(extraField, true);
}
TableReportOptions ops = new TableReportOptions();
ops.topMargin = 0;
ops.bottomMargin = 0;
analyseReporter.setPageOptions(ops);
analyseReporter.finish();
}