DirectoryName dirName = DirectoryLocator.getDirectory(DirectoryName.class);
DirectoryPathron dirPatron = DirectoryLocator.getDirectory(DirectoryPathron.class);
DirectoryReceptionType dirRecType = DirectoryLocator.getDirectory(DirectoryReceptionType.class);
DirectorySocialStatus dirStatus = DirectoryLocator.getDirectory(DirectorySocialStatus.class);
DirectoryDocumentType dirDocType = DirectoryLocator.getDirectory(DirectoryDocumentType.class);
DirectoryRegionIdCode dirRegCode = DirectoryLocator.getDirectory(DirectoryRegionIdCode.class);
dirInsurer = DirectoryLocator.getDirectory(DirectoryInsurer.class);
DirectoryKladr dirKladr = DirectoryLocator.getDirectory(DirectoryKladr.class);
DirectoryKladrType dirKladrType = DirectoryLocator.getDirectory(DirectoryKladrType.class);
DirectoryDiseaseResult dirDisResult = DirectoryLocator.getDirectory(DirectoryDiseaseResult.class);
DirectoryDvr dirDvr = DirectoryLocator.getDirectory(DirectoryDvr.class);
DirectoryDiagnosisEncounter dirDiagEnc = DirectoryLocator.getDirectory(DirectoryDiagnosisEncounter.class);
DirectoryMedicalAidType dirVmu = DirectoryLocator.getDirectory(DirectoryMedicalAidType.class);
DirectoryVisitingPurpose dirVisPurp = DirectoryLocator.getDirectory(DirectoryVisitingPurpose.class);
ErrorList target = new ErrorList();
count = 0;
for (RegisterData data : list) {
if (!needWrite(data)) {
continue;
}
int id = data.id;
//ID
lf.id.put(id, target, data.uuid);
//System.out.println("Запись посещения id = " + id);
//HISTORY
if (data.history.trim().isEmpty()) {
target.add(id, "Номер мед. карты не указан", ErrorList.CLIENT_ERROR);
}
lf.history.put(id, target, data.history);
//FAM
if (data.fam == 0) {
target.add(id, "Фамилия не указана", ErrorList.CLIENT_ERROR);
lf.fam.put(id, target, "");
} else {
String surname = dirSurname.getItemFromID(data.fam).getTitle();
if (surname.trim().isEmpty()) {
target.add(id, "Фамилия пустая", ErrorList.CLIENT_ERROR);
}
lf.fam.put(id, target, surname);
}
//NAM
if (data.nam == 0) {
target.add(id, "Имя не указано", ErrorList.CLIENT_ERROR);
lf.nam.put(id, target, "");
} else {
String name = dirName.getItemFromID(data.nam).getTitle();
if (name.trim().isEmpty()) {
target.add(id, "Имя пустое", ErrorList.CLIENT_ERROR);
}
lf.nam.put(id, target, name);
}
//FNAM
if (data.fnam == 0) {
target.add(id, "Отчество не указано", ErrorList.CLIENT_ERROR);
lf.fnam.put(id, target, "-");
} else {
String patron = dirPatron.getItemFromID(data.fnam).getTitle();
if (patron.trim().isEmpty()) {
target.add(id, "Отчество пустое", ErrorList.CLIENT_ERROR);
patron = "-";
}
lf.fnam.put(id, target, patron);
}
//POL_SER
lf.pol_ser.put(id, target, data.pol_ser);
//POL_NUM
if (data.pol_num.equals("0000000000000000")) {
target.add(id, "Полис фиктивный", ErrorList.CLIENT_ERROR);
}
lf.pol_num.put(id, target, data.pol_num);
//BDAY
if (data.bday == null) {
target.add(id, "Дата рождения не указана", ErrorList.CLIENT_ERROR);
lf.bday.put("");
} else {
Calendar cal = Calendar.getInstance();
cal.setTime(data.bday);
lf.bday.put(cal);
}
//SEX
if (data.sex == 0) {
target.add(id, "Пол не указан", ErrorList.CLIENT_ERROR);
}
lf.sex.put(data.sex);
//STATUS
if (data.status == 0) {
target.add(id, "Социальный статус не указан", ErrorList.CLIENT_ERROR);
lf.status.put(0);
} else {
try {
String extKey = dirStatus.getItemFromID(data.status).getExtKey();
lf.status.put(Integer.parseInt(extKey));
} catch (NumberFormatException ex) {
target.add(id, "Код социального статуса должен быть числом", ErrorList.CLIENT_ERROR);
lf.status.put(0);
}
}
//PRED
lf.pred.put(data.pred);
//P_STATUS
if (data.p_status == 0) {
lf.p_status.put("");
} else {
lf.p_status.put(data.p_status);
}
//P_FAM
if (data.p_fam == 0) {
lf.p_fam.put(id, target, "");
} else {
lf.p_fam.put(id, target, dirSurname.getItemFromID(data.p_fam).getTitle());
}
//P_NAM
if (data.p_nam == 0) {
lf.p_nam.put(id, target, "");
} else {
lf.p_nam.put(id, target, dirName.getItemFromID(data.p_nam).getTitle());
}
//P_FNAM
if (data.p_fnam == 0) {
lf.p_fnam.put(id, target, "");
} else {
lf.p_fnam.put(id, target, dirPatron.getItemFromID(data.p_fnam).getTitle());
}
//C_OKSM
if (data.c_oksm.trim().isEmpty()) {
target.add(id, "Гражданство не указано", ErrorList.CLIENT_ERROR);
}
lf.oksm.put(id, target, data.c_oksm);
//DOC_TYPE
if (data.type_doc == 0) {
lf.doc_type.put(0);
} else {
try {
String extKey = dirDocType.getItemFromID(data.type_doc).getExtKey();
lf.doc_type.put(Integer.parseInt(extKey));
} catch (NumberFormatException ex) {
target.add(id, "Код социального статуса должен быть числом", ErrorList.CLIENT_ERROR);
lf.doc_type.put(0);
}
}
//DOC_SER
lf.doc_ser.put(id, target, data.doc_ser);
//DOC_NUM
lf.doc_num.put(id, target, data.doc_num);
//INS_ID_AR
if (data.ins_id_ar == 0) {
lf.ins_id_ar.put("0");
} else {
try {
String extKey = dirRegCode.getItemFromID(data.ins_id_ar).getExtKey();
lf.ins_id_ar.put(Integer.parseInt(extKey));
} catch (NumberFormatException ex) {
target.add(id, "ИД территории страховой организации должен быть числом", ErrorList.CLIENT_ERROR);
lf.ins_id_ar.put("");
}
}
//INS_ORG
String arExtKey = dirRegCode.getItemFromID(data.ins_id_ar).getExtKey();
DirectoryInsurerItem insurer = dirInsurer.getItemFromID(data.id_ins_org);
if (!arExtKey.equals(RegisterBean.REGION_CODE) && !insurer.getExtKey().isEmpty()) {
lf.ins_org.put(id, target, "");
} else if (data.pol_num.isEmpty() && insurer.getExtKey() != null && !insurer.getExtKey().isEmpty()) {
lf.ins_org.put(id, target, "");