Package clips.main

Examples of clips.main.ClipsConfig


    @Override
    public void updateImpl() throws ClipsException {
        SharedBean<UpdaterClientBeanRemote> bean =
            new SharedBean<UpdaterClientBeanRemote>(UpdaterClientBean.class.getSimpleName());
        ClipsConfig cfg = ClipsConfig.getInstance();

        dirInsurer = DirectoryLocator.getDirectory(DirectoryInsurer.class, true);
        //"Чтение дополнительных полисов"
        File filedop = new File(cfg.getLastDBFImportPath(), "KADR_DOP.DBF");
        DBF dbfDop = createDBF(filedop);
        System.out.println("Чтение дополнительных полисов");
        out.println("Чтение дополнительных полисов");
        //хеш Lnumber, INSUR_ORG
        HashMap<Integer, DirectoryInsurerItem> dopIns = new HashMap<Integer, DirectoryInsurerItem>();
        HashMap<ColDop, Field> fieldsDop = new HashMap<ColDop, Field>();
        try {
            for (int i = 0; i < ColDop.values().length; i++) {
                ColDop col = ColDop.values()[i];
                fieldsDop.put(col, dbfDop.getField(col.toString()));
            }
        } catch (xBaseJException ex) {
            throw new ClipsException("Ошибка при чтении данных из файла " + dbfDop.getName(), ex);
        }
        int recordCount = dbfDop.getRecordCount();
        int counter = 0;
        for (int i = 0; i < recordCount; i++) {
            try {
                dbfDop.read();
                if (dbfDop.deleted()) {
                    continue;
                }
                Integer lnumber = Integer.parseInt(fieldsDop.get(ColDop.LNUMBER).get().trim());
                String insOrg = fieldsDop.get(ColDop.INSUR_ORG).get().trim();
                DirectoryInsurerItem item = dirInsurer.getItemFromTitle(insOrg);
                if (insOrg.isEmpty()) {
                    out.println("Предупреждение : Дополнительный полис не принят " + dbfDop.getName() +
                            " строка " + counter + " причина : insOrg.isEmpty");
                    counter ++;
                    continue;
                }
                if (item == null) {
                    DirectoryItemDetails d = new DirectoryItemDetails(insOrg);
                    d.dirty = true;
                    item = new DirectoryInsurerItem(d);
                    dirInsurer.getItems().append(item);
                }
                dopIns.put(lnumber, item);
            } catch (IOException ex) {
                closeDBF(dbfDop);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbfDop.getName() + " (строка " + i + ")", ex);
            } catch (xBaseJException ex) {
                closeDBF(dbfDop);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbfDop.getName() + " (строка " + i + ")", ex);
            }
            counter ++;
        }
        closeDBF(dbfDop);
        System.out.println("Прочитано " + dopIns.size() + " дополнительных полисов");
        out.println("Прочитано " + dopIns.size() + " дополнительных полисов");





        //Чтение мест работы
        File fileJob = new File(cfg.getLastDBFImportPath(), "S_WORK.DBF");
        DBF dbfJob = createDBF(fileJob);
        System.out.println("Чтение мест работы");
        out.println("Чтение мест работы");
        //хеш ID, NAME организации
        HashMap<String, String> jobMap = new HashMap<String, String>();
        HashMap<ColJob, Field> fieldsJob = new HashMap<ColJob, Field>();
        try {
            for (int i = 0; i < ColJob.values().length; i++) {
                ColJob col = ColJob.values()[i];
                fieldsJob.put(col, dbfJob.getField(col.toString()));
            }
        } catch (xBaseJException ex) {
            throw new ClipsException("Ошибка при чтении данных из файла " + dbfJob.getName(), ex);
        }
        recordCount = dbfJob.getRecordCount();
        counter = 0;
        for (int i = 0; i < recordCount; i++) {
            try {
                dbfJob.read();
                if (dbfJob.deleted()) {
                    continue;
                }
                String id = fieldsJob.get(ColJob.ID).get().trim();
                String name = fieldsJob.get(ColJob.NAME).get().trim();
                if (name.isEmpty()) {
                    out.println("Предупреждение : место работы не принято " + dbfJob.getName() +
                            " ID " + id + " причина : NAME.isEmpty");
                    counter ++;
                    continue;
                }
                jobMap.put(id, name);
            } catch (IOException ex) {
                closeDBF(dbfJob);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbfJob.getName() + " (строка " + i + ")", ex);
            } catch (xBaseJException ex) {
                closeDBF(dbfJob);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbfJob.getName() + " (строка " + i + ")", ex);
            }
            counter ++;
        }
        closeDBF(dbfJob);
        System.out.println("Прочитано " + jobMap.size() + " мест работы");
        out.println("Прочитано " + jobMap.size() + " мест работы");


        //Чтение статталонов - составление белого списка
        System.out.println("Чтение статталонов - составление белого списка пациентов");
        out.println("Чтение статталонов - составление белого списка пациентов");
        File fileSST = new File(cfg.getLastDBFImportPath(), "stat_tal.dbf");
        DBF dbfSST = createDBF(fileSST);
        HashMap<ColSst, Field> fieldsSst = new HashMap<ColSst, Field>();
        try {
            for (int i = 0; i < ColSst.values().length; i++) {
                ColSst col = ColSst.values()[i];
                fieldsSst.put(col, dbfSST.getField(col.toString()));
            }
        } catch (xBaseJException ex) {
            throw new ClipsException("Ошибка при чтении данных из файла " + dbfSST.getName(), ex);
        }
        int counterSst = 0;
        HashSet<Integer> whiteList = new HashSet<Integer>();
        recordCount = dbfSST.getRecordCount();
        for (int i = 0; i < recordCount; i++) {
            try {
                dbfSST.read();
                if (dbfSST.deleted()) {
                    continue;
                }
                if (fieldsSst.get(ColSst.LNUMBER).get().trim().isEmpty()) {
                    counterSst ++;
                    continue;
                }
                whiteList.add(Integer.parseInt(fieldsSst.get(ColSst.LNUMBER).get().trim()));
            } catch (IOException ex) {
                closeDBF(dbfSST);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbfSST.getName() + " (строка " + counterSst + ")", ex);
            } catch (xBaseJException ex) {
                closeDBF(dbfSST);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbfSST.getName() + " (строка " + counterSst + ")", ex);
            } catch (NumberFormatException ex) {
                closeDBF(dbfSST);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbfSST.getName() + " (строка " + counterSst + ")", ex);
            }
        }
        System.out.println("Чтение статталонов - завершено");

        //Чтение основных данных
        File file = new File(cfg.getLastDBFImportPath(),getFilename());
        DBF dbf = createDBF(file);
        HashMap<Col, Field> fields = new HashMap<Col, Field>();
        try {
            for (int i = 0; i < Col.values().length; i++) {
                Col col = Col.values()[i];
View Full Code Here


        Calendar cal = new GregorianCalendar(9999, 99, 99);
        nullDate = cal.getTime();

        SharedBean<UpdaterClientBeanRemote> bean =
            new SharedBean<UpdaterClientBeanRemote>(UpdaterClientBean.class.getSimpleName());
        ClipsConfig cfg = ClipsConfig.getInstance();

        File file = new File(cfg.getLastDBFImportPath(), getFilename());
        DBF dbf = createDBF(file);
        HashMap<Col, Field> fields = new HashMap<Col, Field>();
        try {
            for (int i = 0; i < Col.values().length; i++) {
                Col col = Col.values()[i];
                fields.put(col, dbf.getField(col.toString()));
            }
        } catch (xBaseJException ex) {
            throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName(), ex);
        }
        int recordCount = dbf.getRecordCount();

        System.out.println("Загрузка фамилий, имен, отчеств и профессий");
        out.println("Загрузка фамилий, имен, отчеств и профессий");
        HashSet<String> famList = new HashSet<String>(recordCount);
        HashSet<String> namList = new HashSet<String>(recordCount);
        HashSet<String> patronList = new HashSet<String>(recordCount);
        for (int i = 0; i < recordCount; i++) {
            try {
                dbf.read();
                famList.add(Converter.firstUpper(fields.get(Col.FAM).get().trim(), true));
                namList.add(Converter.firstUpper(fields.get(Col.IM).get().trim(), true));
                patronList.add(Converter.firstUpper(fields.get(Col.OT).get().trim(), true));
            } catch (IOException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " (строка " + i + ")", ex);
            } catch (xBaseJException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " (строка " + i + ")", ex);
            }
        }
        bean.get().updateSurnames(famList);
        dirSurname = DirectoryLocator.getDirectory(DirectorySurname.class, true);
        System.out.println("Фамилии загружены");
        out.println("Фамилии загружены");
        bean.get().updateNames(namList);
        dirName = DirectoryLocator.getDirectory(DirectoryName.class, true);
        System.out.println("Имена загружены");
        out.println("Имена загружены");
        bean.get().updatePatrons(patronList);
        dirPathron = DirectoryLocator.getDirectory(DirectoryPathron.class, true);
        System.out.println("Отчества загружены");
        out.println("Отчества загружены");

        dirDocumentType = DirectoryLocator.getDirectory(DirectoryDocumentType.class, true);
        dirExemption = DirectoryLocator.getDirectory(DirectoryExcemption.class, true);

        try {
            dbf.startTop();
        } catch (IOException ex) {
            throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName(), ex);
        } catch (xBaseJException ex) {
            throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName(), ex);
        }

        int counter = 0;
        GregorianCalendar gc1 = new GregorianCalendar();
        ArrayList<FacilityClientDetails> clientList = new ArrayList<FacilityClientDetails>(recordCount);

        HashMap<String, Integer> snilsMap = new HashMap<String, Integer>();

        for (int i = 0; i < recordCount; i++) {
            try {
                dbf.read();
                if ((counter%500) == 0) {
                    try {
                        UserInfo.get().disturbServer();
                    } catch (Throwable ex) {
                        //пофиг
                    }
                }
                if ((i%1000) == 0) {
                    System.out.println("Обновление льготников: " +  i/((float)recordCount)*100 + "% (" + i + ") запись");
                    GregorianCalendar gc2 = new GregorianCalendar();
                    long mc = gc2.getTimeInMillis() - gc1.getTimeInMillis();
                    System.out.println("Work time: " + mc + " ms");
                }
                if (dbf.deleted()) {
                    continue;
                }

                FacilityClientDetails c = new FacilityClientDetails();

                //код изменения
                int uType = 0;
                try {
                    uType = Integer.parseInt(fields.get(Col.U_TYPE).get().trim());
                    if (uType < 0 || uType > 3) {
                        throw new NumberFormatException();
                    }
                } catch (NumberFormatException ex) {
                    System.out.println("Предупреждение : код изменения некорректен " + dbf.getName() + " snils=(" + c.snils + ")");
                    out.println("Предупреждение : код изменения некорректен " + dbf.getName() + " snils=(" + c.snils + ")");
                    uType = 0;
                }

                String snils = fields.get(Col.SS).get().trim();
                if (snilsMap.containsKey(snils)) {
                    throw new ClipsException("Повторяющийся СНИЛС " + dbf.getName() + " snils=(" + snils + ")" + " строка=" + i);
                }
                snilsMap.put(snils, uType);

                c.snils = snils;
                c.uType = uType;
                c.polisSN = fields.get(Col.SN_POL).get().trim();
                c.surnameId = dirSurname.getItemFromTitle(Converter.firstUpper(fields.get(Col.FAM).get().trim(), true)).getID();
                c.nameId = dirName.getItemFromTitle(Converter.firstUpper(fields.get(Col.IM).get().trim(), true)).getID();
                c.pathronId = dirPathron.getItemFromTitle(Converter.firstUpper(fields.get(Col.OT).get().trim(), true)).getID();

                //пол льготника
                String sex = fields.get(Col.W).get().trim();
                if (sex.toUpperCase().equals("М")) {
                    c.sexId = Sex.CLIENT_SEX_MALE;
                } else if (sex.toUpperCase().equals("Ж")) {
                    c.sexId = Sex.CLIENT_SEX_FEMALE;
                } else {
                    System.out.println("У пациента неопределен пол. " + dbf.getName() + " snils=(" + c.snils + ")");
                    out.println("Предупреждение : У пациента неопределен пол. " + dbf.getName() + " snils=(" + c.snils + ")");
                    c.sexId = Sex.CLIENT_SEX_MALE;
                    String fam = fields.get(Col.FAM).get().trim();
                    if (fam.endsWith("а")) {
                        c.sexId = Sex.CLIENT_SEX_FEMALE;
                    } else {
                        String nam = fields.get(Col.IM).get().trim();
                        if (nam.endsWith("а") || nam.endsWith("я")) {
                            c.sexId = Sex.CLIENT_SEX_FEMALE;
                        }
                    }
                    out.println("Пол выставлен : " + (c.sexId == Sex.CLIENT_SEX_MALE ? "Муж." : "Жен."));
                }

                //дата рождения
                c.bornDate = null;
                try {
                    Calendar bornDate = ((DateField)fields.get(Col.DR)).getCalendar();
                    if (Comparator.dataEqual(nullDate, bornDate.getTime())) {
                        c.bornDate = null;
                    }
                    else {
                        c.bornDate = bornDate.getTime();
                    }
                } catch (NumberFormatException ex) {
                    System.out.println("Предупреждение : Дата рождения пациента некорректна " + dbf.getName() + " snils=(" + c.snils + ")");
                    out.println("Предупреждение : Дата рождения пациента некорректна " + dbf.getName() + " snils=(" + c.snils + ")");
                }

                //документ, удостоверяющий личность
                DirectorySimpleItem doctype = dirDocumentType.getItemFromExtKey(fields.get(Col.C_DOC).get().trim());
                if (doctype == null) {
                    c.docTypeId = 0;
                    System.out.println("Предупреждение : не найден тип документа " + dbf.getName() + " snils=(" + c.snils + ")");
                    out.println("Предупреждение : не найден тип документа " + dbf.getName() + " snils=(" + c.snils + ")");
                }
                else {
                    c.docTypeId = doctype.getID();
                }
                c.docSN = fields.get(Col.SN_DOC).get().trim();

                //адрес, регистрация
                c.address = fields.get(Col.ADRES).get().trim();
                c.building = fields.get(Col.DOM).get().trim();
                c.corpus = fields.get(Col.KOR).get().trim();
                c.flat = fields.get(Col.KV).get().trim();
                c.okatoReg = fields.get(Col.OKATO_REG).get().trim();

                //льготность
                Integer flag = null;
                try {
                    flag = Integer.parseInt(fields.get(Col.S_EDV).get().trim());
                    if (flag < 0 || flag > 1) {
                        throw new NumberFormatException();
                    }
                } catch (NumberFormatException ex) {
                    flag = null;
                    System.out.println("Предупреждение : признак получения НСУ некорректен " + dbf.getName() + " snils=(" + c.snils + ")");
                    out.println("Предупреждение : признак получения НСУ некорректен " + dbf.getName() + " snils=(" + c.snils + ")");
                }
                c.flagNSU = flag;
                c.nsuBegin = null;
                try {
                    Calendar nsuBegin = ((DateField)fields.get(Col.DB_EDV)).getCalendar();
                    if (Comparator.dataEqual(nullDate, nsuBegin.getTime())) {
                        c.nsuBegin = null;
                    }
                    else {
                        c.nsuBegin = nsuBegin.getTime();
                    }
                } catch (NumberFormatException ex) {
                    System.out.println("Предупреждение : Дата начала действия права на получение НСУ некорректна " + dbf.getName() + " snils=(" + c.snils + ")");
                    out.println("Предупреждение : Дата начала действия права на получение НСУ некорректна " + dbf.getName() + " snils=(" + c.snils + ")");
                }
                c.nsuEnd = null;
                try {
                    Calendar nsuEnd = ((DateField)fields.get(Col.DE_EDV)).getCalendar();
                    if (Comparator.dataEqual(nullDate, nsuEnd.getTime())) {
                        c.nsuEnd = null;
                    }
                    else {
                        c.nsuEnd = nsuEnd.getTime();
                    }
                } catch (NumberFormatException ex) {
                    System.out.println("Предупреждение : Дата окончания действия права на получение НСУ некорректна " + dbf.getName() + " snils=(" + c.snils + ")");
                    out.println("Предупреждение : Дата окончания действия права на получение НСУ некорректна " + dbf.getName() + " snils=(" + c.snils + ")");
                }
                DirectorySimpleItem exemp1 = dirExemption.getItemFromExtKey(fields.get(Col.C_KAT1).get().trim());
                if (exemp1 == null) {
                    c.exemp1Id = 0;
                }
                else {
                    c.exemp1Id = exemp1.getID();
                }
                DirectorySimpleItem exemp2 = dirExemption.getItemFromExtKey(fields.get(Col.C_KAT2).get().trim());
                if (exemp2 == null) {
                    c.exemp2Id = 0;
                }
                else {
                    c.exemp2Id = exemp2.getID();
                }

                if (c.exemp1Id == 0 && c.exemp2Id == 0) {
                    System.out.println("Предупреждение : не найдена категория льготности " + dbf.getName() + " snils=(" + c.snils + ")");
                    out.println("Предупреждение : не найдена категория льготности " + dbf.getName() + " snils=(" + c.snils + ")");
                }
                else if (c.exemp1Id != 0 && c.exemp2Id != 0) {
                    System.out.println("Предупреждение : указаны две категории льготности " + dbf.getName() + " snils=(" + c.snils + ")");
                    out.println("Предупреждение : указаны две категории льготности " + dbf.getName() + " snils=(" + c.snils + ")");
                }

                //даты включения в регистр и исключения из регистра
                c.regBegin = null;
                try {
                    Calendar regBegin = ((DateField)fields.get(Col.DATE_RSB)).getCalendar();
                    if (Comparator.dataEqual(nullDate, regBegin.getTime())) {
                        c.regBegin = null;
                    }
                    else {
                        c.regBegin = regBegin.getTime();
                    }
                } catch (NumberFormatException ex) {
                    System.out.println("Предупреждение : Дата включения в региональный Регистр некорректна " + dbf.getName() + " snils=(" + c.snils + ")");
                    out.println("Предупреждение : Дата включения в региональный Регистр некорректна " + dbf.getName() + " snils=(" + c.snils + ")");
                }
                c.regEnd = null;
                try {
                    Calendar regEnd = ((DateField)fields.get(Col.DATE_RSE)).getCalendar();
                    if (Comparator.dataEqual(nullDate, regEnd.getTime())) {
                        c.regEnd = null;
                    }
                    else {
                        c.regEnd = regEnd.getTime();
                    }
                } catch (NumberFormatException ex) {
                    System.out.println("Предупреждение : Дата исключения из регионального Регистра некорректна " + dbf.getName() + " snils=(" + c.snils + ")");
                    out.println("Предупреждение : Дата исключения из регионального Регистра некорректна " + dbf.getName() + " snils=(" + c.snils + ")");
                }

                //признак "особый случай"
                c.dType = fields.get(Col.D_TYPE).get().trim();

                c.c_reg = fields.get(Col.C_REG).get().trim();

                clientList.add(c);
            } catch (IOException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " (строка " + i + ")", ex);
            } catch (xBaseJException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " (строка " + i + ")", ex);
            }
        }
        closeDBF(dbf);
        GregorianCalendar gc2 = new GregorianCalendar();
        long mc = gc2.getTimeInMillis() - gc1.getTimeInMillis();
        System.out.println("Закончилось чтение льготников из файла. Work time: " + mc + " ms");
        out.println("Закончилось чтение льготников из файла. Work time: " + mc + " ms");

       
        File fileDoc = new File(cfg.getLastDBFImportPath(), "C_REGL.DBF");
        DBF dbfDoc = createDBF(fileDoc);
        HashMap<ColDoc, Field> docFields = new HashMap<ColDoc, Field>();
        try {
            for (int i = 0; i < ColDoc.values().length; i++) {
                ColDoc col = ColDoc.values()[i];
View Full Code Here

    }

    @Override
    protected void updateImpl() throws ClipsException {
        dir = DirectoryLocator.getDirectory(DirectoryDloDrugSection.class);
        ClipsConfig cfg = ClipsConfig.getInstance();
        File file = new File(cfg.getLastDBFImportPath(),getFilename());
        DBF dbf = createDBF(file);
        HashMap<Col, Field> fields = new HashMap<Col, Field>();
        try {
            for (int i = 0; i < Col.values().length; i++) {
                Col col = Col.values()[i];
View Full Code Here

    }


    @Override
    final public void updateImpl() throws ClipsException {
        ClipsConfig cfg = ClipsConfig.getInstance();
        File file = new File(cfg.getLastDBFImportPath(),getFilename());
        DBF dbf = createDBF(file);
        HashMap<String, Field> fields = new HashMap<String, Field>();
        try {
            fields.put("ID", dbf.getField(idField));
            fields.put("NAME", dbf.getField(titleField));
View Full Code Here

        for (DirectoryCollaboratorItem item : list) {
            String code = lpuOGRN + " " + item.getCode();
            collMap.put(code, item);
        }

        ClipsConfig cfg = ClipsConfig.getInstance();

        File file = new File(cfg.getLastDBFImportPath(), getFilename());
        DBF dbf = createDBF(file);
        HashMap<Col, Field> fields = new HashMap<Col, Field>();
        try {
            for (int i = 0; i < Col.values().length; i++) {
                Col col = Col.values()[i];
View Full Code Here

        return "Перечень льготных ЛС";
    }

    @Override
    protected void updateImpl() throws ClipsException {
        ClipsConfig cfg = ClipsConfig.getInstance();

        Calendar cal = new GregorianCalendar(9999, 99, 99);
        nullDate = cal.getTime();

        DirectoryDrugList drugList = DirectoryLocator.getDirectory(DirectoryDrugList.class);
        dirTradeName = DirectoryLocator.getDirectory(DirectoryDrugTradeName.class);
        dirMNN = DirectoryLocator.getDirectory(DirectoryDrugMNN.class);
        dirDosageForm = DirectoryLocator.getDirectory(DirectoryDrugDosageForm.class);
        dirDosageUnit = DirectoryLocator.getDirectory(DirectoryDrugDosageUnit.class);
        dirVolumeUnit = DirectoryLocator.getDirectory(DirectoryDrugVolumeUnit.class);
        dirWeightUnit = DirectoryLocator.getDirectory(DirectoryDrugWeightUnit.class);
        dirFarmGroup = DirectoryLocator.getDirectory(DirectoryDrugFarmGroup.class);
        dirSection = DirectoryLocator.getDirectory(DirectoryDloDrugSection.class);

        File file = new File(cfg.getLastDBFImportPath(),getFilename());
        DBF dbf = createDBF(file);
        HashMap<Col, Field> fields = new HashMap<Col, Field>();
        try {
            for (int i = 0; i < Col.values().length; i++) {
                Col col = Col.values()[i];
View Full Code Here

    }

    @Override
    public void updateImpl() throws ClipsException {
        collabList = null;
        ClipsConfig cfg = ClipsConfig.getInstance();
        dirVmu = DirectoryLocator.getDirectory(DirectoryMedicalAidType.class);

        //Замаппируем пациентов по lnumber
        File file = new File(cfg.getLastDBFImportPath(), "KADR.DBF");
        DBF dbf = createDBF(file);
        HashMap<ColKadr, Field> fieldsKadr = new HashMap<ColKadr, Field>();
        try {
            for (int i = 0; i < ColKadr.values().length; i++) {
                ColKadr col = ColKadr.values()[i];
                fieldsKadr.put(col, dbf.getField(col.toString()));
            }
        } catch (xBaseJException ex) {
            throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName(), ex);
        }
        int recordCount = dbf.getRecordCount();
        DirectorySurname dirSurname = DirectoryLocator.getDirectory(DirectorySurname.class);
        DirectoryName dirName = DirectoryLocator.getDirectory(DirectoryName.class);
        DirectoryPathron dirPathron = DirectoryLocator.getDirectory(DirectoryPathron.class);
        DirectoryDisabilityType dirDisability = DirectoryLocator.getDirectory(DirectoryDisabilityType.class);
        ArrayList<LNumberChunk> lNumberChunkList = new ArrayList<LNumberChunk>(recordCount);
        HashSet<Integer> lnumSet = new HashSet<Integer>();
        for (int i = 0; i < recordCount; i++) {
            try {
                dbf.read();
                if (dbf.deleted()) {
                    continue;
                }
                LNumberChunk c = new LNumberChunk();
                c.lnumber = Integer.parseInt(fieldsKadr.get(ColKadr.LNUMBER).get().trim());
                if (lnumSet.contains(c.lnumber)) {
                    continue;
                } else {
                    lnumSet.add(c.lnumber);
                }


                c.famID = dirSurname.getItemFromTitle(Converter.firstUpper(fieldsKadr.get(ColKadr.FAMILY).get().trim(), true)).getID();
                c.nameID = dirName.getItemFromTitle(Converter.firstUpper(fieldsKadr.get(ColKadr.NAME).get().trim(), true)).getID();
                c.patronID = dirPathron.getItemFromTitle(Converter.firstUpper(fieldsKadr.get(ColKadr.FATHER).get().trim(), true)).getID();
                c.born = null;
                try {
                    Calendar bornDate = ((DateField)fieldsKadr.get(ColKadr.BITHDATE)).getCalendar();
                    bornDate.set(Calendar.HOUR_OF_DAY, 0);
                    bornDate.set(Calendar.MINUTE, 0);
                    bornDate.set(Calendar.SECOND, 0);
                    bornDate.set(Calendar.MILLISECOND, 0);
                    c.born = bornDate.getTime();
                } catch (NumberFormatException ex) {
                    //System.out.println("Ошибка при чтении даты рождения пациента " + dbf.getName() + " (строка " + i + ")");
                }
                lNumberChunkList.add(c);
            } catch (IOException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " (строка " + i + ")", ex);
            } catch (xBaseJException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " (строка " + i + ")", ex);
            } catch (NumberFormatException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " (строка " + i + ")", ex);
            }
        }
        closeDBF(dbf);
        try {
            clientMap = updaterStattalonBean.get().getClientMap(lNumberChunkList);
        } catch (ClipsServerException ex) {
            throw new ClipsException("Не удалось загрузить пациентов", ex);
        }
        lNumberChunkList = null;
        lnumSet = null;
        System.gc();
        System.out.println("Пациенты прогружены");
        out.println("Пациенты прогружены");





        //Замаппируем статталоны (наши заболевания) по N_SYST
        file = new File(cfg.getLastDBFImportPath(), "stat_tal.dbf");
        dbf = createDBF(file);
        HashMap<ColSst, Field> fieldsSst = new HashMap<ColSst, Field>();
        try {
            for (int i = 0; i < ColSst.values().length; i++) {
                ColSst col = ColSst.values()[i];
                fieldsSst.put(col, dbf.getField(col.toString()));
            }
        } catch (xBaseJException ex) {
            throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName(), ex);
        }
        sstMap = new HashMap<Integer, SstData>();
        doubleSstMap = new HashMap<Integer, HashSet<SstData>>();
        int counterSst = 0;
        recordCount = dbf.getRecordCount();
        for (int i = 0; i < recordCount; i++) {
            try {
                dbf.read();
                if (dbf.deleted()) {
                    continue;
                }
                SstData d = new SstData();
                if (fieldsSst.get(ColSst.N_SYST).get().trim().isEmpty()) {
                    System.out.println("Ошибка : В статталоне отсутствует N_SYST " + dbf.getName());
                    out.println("Ошибка : В статталоне отсутствует N_SYST " + dbf.getName());
                    counterSst ++;
                    continue;

                }
                d.nSyst = Integer.parseInt(fieldsSst.get(ColSst.N_SYST).get().trim());
                if (fieldsSst.get(ColSst.LNUMBER).get().trim().isEmpty()) {
                    System.out.println("Ошибка : Отсутствует LNUMBER в статталоне N_SYST = " + d.nSyst + " "+ dbf.getName());
                    out.println("Ошибка : Отсутствует LNUMBER в статталоне N_SYST = " + d.nSyst + " "+ dbf.getName());
                    counterSst ++;
                    continue;
                }
                d.lnumber = Integer.parseInt(fieldsSst.get(ColSst.LNUMBER).get().trim());
                if (!clientMap.containsKey(d.lnumber)) {
                    //Возможно пофиксится потом, вызовом fixSstLnumber, там и будет вывод ошибки
                    //System.out.println("Ошибка : Неправильный LNUMBER в статталоне N_SYST = " + d.nSyst + " LNUMBER = " + d.lnumber + " "+ dbf.getName());
                    //out.println("Ошибка : Неправильный LNUMBER в статталоне N_SYST = " + d.nSyst + " LNUMBER = " + d.lnumber + " "+ dbf.getName());
                }

                d.bithdate = null;
                try {
                    Calendar cal = ((DateField)fieldsSst.get(ColSst.BITHDATE)).getCalendar();
                    d.bithdate = DateTimeUtils.getDateOnly(cal).getTime();
                } catch (NumberFormatException e) {
                    //Дата рождения в статталоне не указана
                }

                d.dataSt = null;
                try {
                    Calendar cal = ((DateField)fieldsSst.get(ColSst.DATA_ST)).getCalendar();
                    d.dataSt = DateTimeUtils.getDateOnly(cal).getTime();
                } catch (NumberFormatException ex) {
                    //оставляем нулл, потом скорректируется по посещению fixSstLnumber();
                }
                d.vmu = fieldsSst.get(ColSst.VMU).get().trim();
                d.purpose = fieldsSst.get(ColSst.CELX).get().trim();
                d.idWrach = Integer.parseInt(fieldsSst.get(ColSst.WRACH).get().trim());
                d.result = fieldsSst.get(ColSst.REZULT).get().trim();
                d.place = fieldsSst.get(ColSst.MESTO).get().trim();
                d.blBeg = null;
                try {
                    Calendar date = ((DateField)fieldsSst.get(ColSst.BL_D_BEG)).getCalendar();
                    date.set(Calendar.HOUR_OF_DAY, 0);
                    date.set(Calendar.MINUTE, 0);
                    date.set(Calendar.SECOND, 0);
                    date.set(Calendar.MILLISECOND, 0);
                    d.blBeg = date.getTime();
                } catch (NumberFormatException ex) {
                    //значение даты не удалось прочитать - оставляем нулл
                }
                d.blEnd = null;
                try {
                    Calendar date = ((DateField)fieldsSst.get(ColSst.BL_D_END)).getCalendar();
                    date.set(Calendar.HOUR_OF_DAY, 0);
                    date.set(Calendar.MINUTE, 0);
                    date.set(Calendar.SECOND, 0);
                    date.set(Calendar.MILLISECOND, 0);
                    d.blEnd = date.getTime();
                } catch (NumberFormatException ex) {
                    //значение даты не удалось прочитать - оставляем нулл
                }
                DirectoryDisabilityTypeItem disType = dirDisability.getItemFromExtKey(fieldsSst.get(ColSst.BL_PRICH).get().trim());
                d.blPrich = disType == null ? 0 : disType.getID();
                d.blAge = fieldsSst.get(ColSst.BL_UH_LET).get().trim();
                d.blSex = fieldsSst.get(ColSst.BL_UH_SEX).get().trim();
                d.stomMkb = fieldsSst.get(ColSst.STOM1).get().trim() + fieldsSst.get(ColSst.STOM2).get().trim();
                d.stomHarak = fieldsSst.get(ColSst.STOM_HARAK).get().trim();
                d.received = fieldsSst.get(ColSst.F12).get().trim().equals("9");
                d.data = null;
                try {
                    Calendar date = ((DateField)fieldsSst.get(ColSst.DATA)).getCalendar();
                    date.set(Calendar.HOUR_OF_DAY, 0);
                    date.set(Calendar.MINUTE, 0);
                    date.set(Calendar.SECOND, 0);
                    date.set(Calendar.MILLISECOND, 0);
                    d.data = date.getTime();
                } catch (NumberFormatException ex) {
                    System.out.println("Ошибка : Отсутствует дата закрытия в статталоне N_SYST = " + d.nSyst + " "+ dbf.getName());
                    out.println("Ошибка : Отсутствует дата закрытия в статталоне N_SYST = " + d.nSyst + " "+ dbf.getName());
                    counterSst ++;
                    continue;
                }

                if (sstMap.containsKey(d.nSyst)) {
                    //Дубликаты запихнем в отдельный мап дубликатов для дальнейшей корректировки
                    HashSet<SstData> set = doubleSstMap.get(d.nSyst);
                    if (set == null) {
                        set = new HashSet<SstData>();
                        doubleSstMap.put(d.nSyst, set);
                    }
                    set.add(sstMap.get(d.nSyst));
                    set.add(d);
                } else {
                    sstMap.put(d.nSyst, d);
                }
            } catch (IOException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " (строка " + counterSst + ")", ex);
            } catch (xBaseJException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " (строка " + counterSst + ")", ex);
            } catch (NumberFormatException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " (строка " + counterSst + ")", ex);
            }
            counterSst ++;
        }
        closeDBF(dbf);
        System.out.println("Статталоны прогружены");
        out.println("Статталоны прогружены");



        //Прогрузка посещений
        /*Посещения прогружаются и сасовываются в статталоны по совпадению N_SYST*/
        System.out.println("Прогрузка посещений");
        out.println("Прогрузка посещений");
        file = new File(cfg.getLastDBFImportPath(), "stat_dni.dbf");
        dbf = createDBF(file);
        HashMap<ColDni, Field> fieldsDni = new HashMap<ColDni, Field>();
        try {
            for (int i = 0; i < ColDni.values().length; i++) {
                ColDni col = ColDni.values()[i];
                fieldsDni.put(col, dbf.getField(col.toString()));
            }
        } catch (xBaseJException ex) {
            throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName(), ex);
        }
        int counterDni = 0;
        recordCount = dbf.getRecordCount();
        for (int i = 0; i < recordCount; i++) {
            try {
                dbf.read();
                if (dbf.deleted()) {
                    continue;
                }
                DniData d = new DniData();
                if (fieldsDni.get(ColDni.N_SYST).get().trim().isEmpty()) {
                    System.out.println("Ошибка : В посещении отстутствует N_SYST, строка  " + counterDni + " "+ dbf.getName());
                    out.println("Ошибка : В посещении отстутствует N_SYST, строка  " + counterDni + " "+ dbf.getName());
                    counterDni ++;
                    continue;
                }
                Integer nSyst = Integer.parseInt(fieldsDni.get(ColDni.N_SYST).get().trim());
                SstData sst = sstMap.get(nSyst);
                if (sst == null) {
                    System.out.println("Ошибка : Для посещения не найден статталон, N_SYST = " + nSyst + " " + dbf.getName());
                    out.println("Ошибка : Для посещения не найден статталон, N_SYST = " + nSyst + " " + dbf.getName());
                    counterDni ++;
                    continue;
                }
                d.date = null;
                try {
                    Calendar date = ((DateField)fieldsDni.get(ColDni.DATA)).getCalendar();
                    d.date = DateTimeUtils.getDateOnly(date).getTime();
                } catch (NumberFormatException ex) {
                    System.out.println("Ошибка : Отсутствует дата посещения, N_SYST = " + nSyst + " " + dbf.getName());
                    out.println("Ошибка : Отсутствует дата посещения, N_SYST = " + nSyst + " " + dbf.getName());
                    counterDni ++;
                    continue;
                }
                d.mes = fieldsDni.get(ColDni.MES).get().trim();
                d.uet = fieldsDni.get(ColDni.UET).get().trim();
                if (d.mes.length() == 6){
                    //Нормальное посещение
                    d.uet = "1";
                } else if (!d.uet.isEmpty() && !d.uet.equals("0")) {
                    //Стоматологическое посещение
                    d.mes = "629000";
                    DsData ds = new DsData();
                    ds.nSyst = nSyst;
                    ds.lnumber = sst.lnumber;
                    ds.tip = "З";
                    ds.mkb = sst.stomMkb;
          ds.encounter = sst.stomHarak;
                    ds.trawma = "";
                    ds.dateReg = d.date;
                    d.dsDataList.add(ds);
                } else {
                    System.out.println("Ошибка : Неправильное поле MES, N_SYST = " + nSyst + " " + dbf.getName());
                    out.println("Ошибка : Неправильное поле MES, N_SYST = " + nSyst + " " + dbf.getName());
                    counterDni ++;
                    continue;
                }
                d.idWrach = Integer.parseInt(fieldsDni.get(ColDni.IDWRACH).get().trim());
                sst.dniList.add(d);
            } catch (IOException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " (строка " + i + ")", ex);
            } catch (xBaseJException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " (строка " + i + ")", ex);
            } catch (NumberFormatException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " (строка " + i + ")", ex);
            }
            counterDni ++;
        }
        closeDBF(dbf);
        System.out.println("Посещения прогружены");
        out.println("Посещения прогружены");



        //
        /*ds это диагнозы, их надо закидывать в посещения, соответствующие по nsyst
         * причем диагноз надо закидывать в посещение обслуженное лечащим врачем ближайшее по дате
         * предусмотреть случаи чтобы в посещении не было двух заключительных диагнозов
         * */
        followMap = new HashMap<FollowUpKey, ArrayList<EventKey>>();
        file = new File(cfg.getLastDBFImportPath(), "stat_ds.dbf");
        dbf = createDBF(file);
        HashMap<ColDS, Field> fieldsDs = new HashMap<ColDS, Field>();
        try {
            for (int i = 0; i < ColDS.values().length; i++) {
                ColDS col = ColDS.values()[i];
View Full Code Here

    @Override
    protected void updateImpl() throws ClipsException {
        dirCollab = DirectoryLocator.getDirectory(DirectoryCollaborator.class);
        collabList = null;
        clientSearchLocal = new ClientSearchLocal(am);
        ClipsConfig cfg = ClipsConfig.getInstance();
        File file = new File(cfg.getLastDBFImportPath(),getFilename());
        DBF dbf = createDBF(file);
        HashMap<Col, Field> fields = new HashMap<Col, Field>();
        try {
            for (int i = 0; i < Col.values().length; i++) {
                Col col = Col.values()[i];
View Full Code Here

    }

    @Override
    public void updateImpl() throws ClipsException {
        dir = DirectoryLocator.getDirectory(DirectoryKladrType.class);
        ClipsConfig cfg = ClipsConfig.getInstance();
        File file = new File(cfg.getLastDBFImportPath(),getFilename());
        DBF dbf = createDBF(file);
        HashMap<String, Field> fields = new HashMap<String, Field>();
        try {
            fields.put("ID", dbf.getField("ID"));
            fields.put("CUTNAME", dbf.getField("CUTNAME"));
View Full Code Here

            }
        }

        HashSet<VisitPrice> visitPriceSet = new HashSet<VisitPrice>();

        ClipsConfig cfg = ClipsConfig.getInstance();
        {
            File file = new File(cfg.getLastDBFImportPath(), S_VISIT);
            DBF dbfVisit = createDBF(file);
            HashMap<ColVisit, Field> fieldsVisit = new HashMap<ColVisit, Field>();
            try {
                for (int i = 0; i < ColVisit.values().length; i++) {
                    ColVisit col = ColVisit.values()[i];
                    fieldsVisit.put(col, dbfVisit.getField(col.toString()));
                }
            } catch (xBaseJException ex) {
                throw new ClipsException("Ошибка при чтении данных из файла " + dbfVisit.getName(), ex);
            }

            int recordCount = dbfVisit.getRecordCount();
            for (int c = 0; c < recordCount; c++) {
                try {
                    dbfVisit.read();
                    String id = fieldsVisit.get(ColVisit.ID).get().trim();
                    String price = fieldsVisit.get(ColVisit.PRICE).get().trim();
                    visitPriceSet.add(new VisitPrice(id, price));
                    System.out.println(id + " " + price);
                } catch (IOException ex) {
                    closeDBF(dbfVisit);
                    throw new ClipsException("Ошибка при чтении данных из файла " + dbfVisit.getName(), ex);
                } catch (xBaseJException ex) {
                    closeDBF(dbfVisit);
                    throw new ClipsException("Ошибка при чтении данных из файла " + dbfVisit.getName(), ex);
                }
            }
            closeDBF(dbfVisit);
        }

        {
            File file = new File(cfg.getLastDBFImportPath(), S_UET);
            DBF dbfUET = createDBF(file);
            HashMap<ColUet, Field> fieldsUet = new HashMap<ColUet, Field>();
            try {
                for (int i = 0; i < ColVisit.values().length; i++) {
                    ColUet col = ColUet.values()[i];
View Full Code Here

TOP

Related Classes of clips.main.ClipsConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.