public void formPrintFields(DirectoryCollaboratorFunctionsItem collab) throws ClipsException {
ClientLocal client = getEmcLocal().getClient();
DiseaseFolluwupPrintInfo printInfo = getPrintInfo();
DirectoryMKB10 mKB10 = DirectoryLocator.getDirectory(DirectoryMKB10.class);
ArrayList<SerRenLocal> serrensInTap = getSerRensByCollab(collab);
data = new HashMap<String, Object>();
String emcNum = getEmcLocal().getClient().getNumberEmc();
if (emcNum != null) {
data.put("emc_code", emcNum);
}
data.put("tap_date", Converter.dateToString(getCreated(), "dd.MM.yy"));
DirectoryDistrictItem dist = client.getDistrict();
if (dist != null && dist.getID() != 0) {
String district = dist.getTitle();
data.put("pacient_district", district);
}
String snils = client.getSnils();
if (snils != null) {
data.put("pacient_snils", snils);
}
ClientExemptionData chunk = client.getExemption();
if (chunk != null) {
DirectoryExcemptionItem exemp = chunk.getExemption();
if (exemp != null && exemp.getID() != 0) {
data.put("exemption_code", exemp.getExtKey());
}
}
data.put("pacient_fio", client.toString());
data.put("pacient_sex", client.getSex().getID());
String bornDate = Converter.dateToString(client.getBorn());
data.put("pacient_born_date", bornDate.isEmpty() ? " " : bornDate);
ClientLocal representative = null;
if (client.getPolisOMS().getNumber().equals(Polis.FICTIVE_POLIS_NUMBER)) {
representative = client.getRepresentative();
}
ClientDocumentData doc;
PolisData polis;
if (representative != null) {
data.put("representative_surname", representative.getSurname().getTitle());
data.put("representative_name", representative.getName().getTitle());
data.put("representative_patron", representative.getPathron().getTitle());
data.put("is_representative_document", Boolean.TRUE);
DirectoryRepresentativeStatusItem item = client.getRepresStatus();
if (item != null) {
data.put("representative_status", item.getID());
}
doc = representative.getClientDocument();
polis = representative.getPolisOMS();
}
else {
doc = client.getClientDocument();
polis = client.getPolisOMS();
}
if (doc != null) {
data.put("pacient_document_title", doc.getType().getTitle());
String docS = doc.getSeries();
if (docS != null) {
data.put("pacient_document_series", docS);
}
docS = doc.getNumber();
if (docS != null) {
data.put("pacient_document_number", docS);
}
}
if (polis != null) {
String polisS = polis.getSeries();
if (polisS != null) {
data.put("polis_series", polisS);
}
polisS = polis.getNumber();
if (polisS != null) {
data.put("polis_number", polisS);
}
DirectoryRegionIdCodeItem regItem = polis.getRegionCode();
if (regItem != null && regItem.getID()!=0) {
data.put("polis_area", regItem.getRegionTitle());
}
DirectoryInsurerItem ins = polis.getInsurer();
if (ins != null && ins.getID() != 0) {
data.put("polis_insurer", ins.getTitle());
}
Date date = polis.getFromDate();
if (date != null) {
data.put("polis_begin_date", Converter.dateToString(date));
}
date = polis.getTillDate();
if (date != null) {
data.put("polis_end_date", Converter.dateToString(date));
}
data.put("polis_giver", "");//TODO кого сюда пихать? Парамаетр - "Кем выдан"
}
Address address = client.getAddress();
if (address != null) {
data.put("address_index", address.getZipCode() !=0 ? Integer.toString(address.getZipCode()) : "");
data.put("address_region", address.getRegionTitle());
data.put("address_town", address.getAreaOrCity());
data.put("address_village", address.getVillageOrCityDistrict());
data.put("address_village_type", address.getSettlementType() != null ?
address.getSettlementType().getTitle() : "");
data.put("address_street", address.getStreetTitle());
data.put("address_street_type", address.getStreet().getType() != null ?
address.getStreet().getType().getTitle() : "");
data.put("building_number", Converter.getBuildingNumber(address.getBuilding()));
data.put("building_corps", Converter.getBuildingCorpus(address.getBuilding()));
data.put("building_letter", Converter.getBuildingLetter(address.getBuilding()));
data.put("flat_number", address.getFlat() == null ? "" : address.getFlat());
if (address.isCitizen() != null) {
data.put("pacient_resident", address.isCitizen() ? CONST_1 : CONST_2);
}
}
JobLocal job = client.getLastJob();
if (job != null && job.getEnterprise() != null) {
data.put("pacient_job", job.getEnterprise().getTitle());
}
if (client.getSocialStatus() != null && client.getSocialStatus().getID() != 0 ) {
data.put("soc_stat", client.getSocialStatus().getID());
}
//TODO инвалидность
//TODO вид оплаты. пока всегда ОМС
data.put("pay_type", CONST_1);
String collab_code = collab.getReceptionType().getExtKey();
data.put("collaborator_code", collab_code);
data.put("collaborator_fio", collab.getCollaborator().getTitle());
DirectoryMedicalAidTypeItem aidTypeItem = collab.getFirstMedicalAid();
if (aidTypeItem != null && aidTypeItem.getID() != 0) {
data.put("medical_aid_type", aidTypeItem.getExtKey());
}
DirectoryServicingPlaceItem dspi = serrensInTap.get(0).getServicingPlace();
System.out.println("SERVICING PLACE: " + dspi);
data.put("servicing_place", dspi != null ? dspi.getID() : 0);
if (getVisitingPurpose() != null && getVisitingPurpose().getID() != 0) {
data.put("visiting_purpose", getVisitingPurpose().getID());
}
if (getDiseaseResult() != null && getDiseaseResult().getID() != 0) {
data.put("disease_result", getDiseaseResult().getID());
}
ArrayList<String> serDates = new ArrayList<String>();
ArrayList<String> serTitles = new ArrayList<String>();
ArrayList<String> serUets = new ArrayList<String>();
//TODO если посещение по МЭС, то УКЛ (уровень качества лечения)
ArrayList<String> serUKLs = new ArrayList<String>();
for (int i = 0; i < serrensInTap.size(); i++) {
SerRenLocal serRen = serrensInTap.get(i);
serDates.add(Converter.dateToString(serRen.getSerRenderDate(), "dd.MM.yy"));
serTitles.add(serRen.getService().getFullCode());
if (serRen.getCollaboratorFunctions().getReceptionType().getExtKey().contains("29")) {
serUets.add(Double.toString(serRen.getUet()/100));
}
}
data.put("service_dates", serDates);
data.put("service_titles", serTitles);
data.put("service_UKL", serUKLs);
data.put("service_uet", serUets);
DiagnosisLocal preliminary = getDiagsByType(serrensInTap, DiagnosisType.DIAGNOSIS_TYPE_PRELIMINARY);
if (preliminary != null) {
data.put("diagnosis_presumptive_code", preliminary.getMkb().getDiseaseCode());
data.put("diagnosis_presumptive_date", Converter.dateToString(preliminary.getDate(), "dd.MM.yy"));
}
DiagnosisLocal specDiag = getSpecificDiagnosis();
if (specDiag != null) { //&& finalD.getSerrenLocal().getCollaboratorFunctions().getID() == collab.getID()) {
data.put("diagnosis_final_code", specDiag.getMkb().getDiseaseCode());
data.put("diagnosis_final_date", Converter.dateToString(specDiag.getDate(), "dd.MM.yy"));
data.put("diagnosis_final_encounter", specDiag.getEncounter().getID());
data.put("followup_final", printInfo.mainFollowStage);
data.put("followup_down_final", printInfo.mainFollowDownReason);
if ((specDiag.getTrauma()!=null
&& specDiag.getTrauma().getExtKey() != null)
&& !specDiag.getTrauma().getExtKey().isEmpty()){
data.put("trauma_type", specDiag.getTrauma().getID());
}
data.put("diagnosis_associated_code_0", mKB10.getItemFromID(printInfo.attendant0DiagnosisMkbID).getDiseaseCode());
data.put("diagnosis_associated_encounter_0", printInfo.attendant0DiagnosisEncounter);
data.put("followup_associated_0", printInfo.attendant0FollowStage);
data.put("followup_down_associated_0", printInfo.attendant0FollowDownReason);
data.put("diagnosis_associated_code_1", mKB10.getItemFromID(printInfo.attendant1DiagnosisMkbID).getDiseaseCode());
data.put("diagnosis_associated_encounter_1", printInfo.attendant1DiagnosisEncounter);
data.put("followup_associated_1", printInfo.attendant1FollowStage);
data.put("followup_down_associated_1", printInfo.attendant1FollowDownReason);
DirectoryMKB10Item compl = specDiag.getComplication();