Package beans.doctor.disease

Examples of beans.doctor.disease.Disease


    public TransportData createItem(ProfcheckupItemChunk itemChunk) throws ClipsServerException {
        /**кеш эмк ид клиента - эмк*/
        Map<Integer, Emc> emcMap = new HashMap<Integer, Emc>();
        //создадим и заполним итемы
        ProfcheckupItem pchItem = new ProfcheckupItem();//сюда приходят только новые итемы
        Disease disease = null;
        Field[] fs = new Field[]{
            new Field("polis.id", itemChunk.polisID),
            new Field("profcheckup.id", itemChunk.profcheckupId)       
        };
        List list = findEntityList(ProfcheckupItem.class, fs);
        if (list != null && !list.isEmpty()) {//если в профчекапе уже есть итемы
            disease = ((ProfcheckupItem) list.get(0)).getDisease();
            //Вполне возможно наличие в заболевании услуг, нет необходимости их назначать заново
            //поэтому выбросим их из списка необходимых услуг
            //и хер с ней оказана она или нет
            Field[] f = new Field[]{new Field("disease", disease)};
            Iterator iterator = findEntityList(ServiceRender.class, f).iterator();
            while (iterator.hasNext()) {
                ServiceRender sr = (ServiceRender)iterator.next();
                Iterator<ServiceCheckupChunk> servIter = itemChunk.serviceList.iterator();
                while (servIter.hasNext()) {
                    ServiceCheckupChunk chunk = servIter.next();
                    if (chunk.serviceID == sr.getService().getId()){
                        servIter.remove();//выкидываем услугу
                    }
                }
            }
        } else {
//            pchItem = new ProfcheckupItem();
            disease = new Disease();//сделаем заболевание
            Date current = new Date();
            disease.setCreated(current);//дата по первому созданию
            disease.setDateReg(current);
        }

        Polis polis = findEntity(Polis.class, itemChunk.polisID);
        Integer clientID = polis.getClient().getId();
        Field[] f = {new Field("client.id", clientID)};
        Iterator it = findEntityList(Emc.class, f).iterator();
        if (emcMap.get(clientID) == null) {//проверим в кеше
            Emc emc;
            if (it.hasNext()) {
                emc = (Emc) it.next();
            } else {
                throw new EDataIntegrity("у пациента " + polis.getClient().getSurname() + " " +
                        polis.getClient().getName() + " " + polis.getClient().getPathronymic() +
                        " нет медицинской карты");
            }
            emcMap.put(clientID, emc);
        }
        disease.setEmc(emcMap.get(clientID));
        disease.setCollaborator(findEntity(Collaborator.class, getCollaboratorId()));
        if (disease.getId() == 0) {
            manager.persist(disease);//теперь есть заболевание, мона его юзать(или нет?)
        } else {
            disease = manager.merge(disease);
        }
        manager.flush();
        manager.refresh(disease);

        //заполним профчекапитем
        pchItem.setPolis(polis);
        pchItem.setPassed(false);
        pchItem.setDanger(findEntity(Danger.class, itemChunk.dangerId));
        pchItem.setProfcheckup(findEntity(Profcheckup.class, itemChunk.profcheckupId));
        pchItem.setDisease(disease);
        manager.persist(pchItem);//теперь есть профчекапитем, мона его юзать
        manager.flush();
        manager.refresh(pchItem);
        //Пометим список услуг что они с дангерами
        for (int i = 0; i < itemChunk.serviceList.size(); i++) {
            ServiceCheckupChunk scc = itemChunk.serviceList.get(i);
            scc.dangerID = itemChunk.dangerId;
        }
        //создадим услугу
        NewServicesChunk chunk = new NewServicesChunk(disease.getId(),
                                                0,
                                                polis.getDetails(this),
                                                0,
                                                itemChunk.serviceList,
                                                new HashMap<Integer, Integer>());
View Full Code Here


        FollowupEvent event = findEntity(FollowupEvent.class, details.id);
        checkTheSame(event.getFollup());
        AuditDoc<FollowupEvent> auditFevent = new AuditDoc<FollowupEvent>(event, getCollaborator());
        auditDoclList.add(auditFevent);
        Disease disease = new Disease();//сделаем заболевание
        AuditDoc<Disease> auditDisease = new AuditDoc<Disease>(disease, getCollaborator());
        auditDoclList.add(auditDisease);
        Date current = new Date();
        disease.setCreated(current);//дата по первому созданию
        disease.setVisitingPurpose(findEntity(VisitingPurpose.class, VisitingPurpose.VP_FOLLOWUP));
        disease.setDateReg(details.date);
        disease.setEmc(getExistentEntity().getSerrenUp().getDisease().getEmc());
        disease.setCollaborator(findEntity(Collaborator.class, getCollaboratorId()));
        event.setDisease(disease);
        manager.persist(disease);
        manager.merge(event);
        manager.flush();
        manager.refresh(disease);
        manager.refresh(event);
        auditFevent.check(event);
        auditDisease.check(disease);
        return new ModDisease(persistAudit(auditDoclList), disease.getDetails(this));
    }
View Full Code Here

            srbl.initByID(serren.getId(), getSessionId());
            ServiceRenderBean.breakPacket(manager, serren, getCollaborator(), auditDocLsit);
            srbl.onRemove(serren, auditDocLsit);
            ServiceRenderBean.remove(manager, serren, getCollaborator(), auditDocLsit);
        }
        Disease disease = entity.getDisease();
        manager.remove(disease);
  }
View Full Code Here

        HashMap<Disease, DiagnosisDetails> map = DiseaseBean.getSpecificDiagnosis(entity, manager);

        Iterator i = list.iterator();
        List<Pair<DiseaseDetails, DiagnosisDetails>> detailsList = new ArrayList<Pair<DiseaseDetails, DiagnosisDetails>>();
        while(i.hasNext()) {
            Disease s = (Disease) i.next();
            DiagnosisDetails diagnosysDiagnosis = map.get(s);
            DiseaseDetails diseaseDetails = s.getDetails((RightChecker) this);
            detailsList.add(new Pair<DiseaseDetails, DiagnosisDetails>(diseaseDetails, diagnosysDiagnosis));
        }
        return detailsList;
    }
View Full Code Here

            }
        }
        if (serren == null) {
            return null;
        }
        Disease disease = serren.getDisease();
        return DiseaseBean.getSpecificDiagnosis(disease, manager);
    }
View Full Code Here

    HashMap<Disease, DiseaseRange>    ranges = new HashMap<Disease, DiseaseRange>();
    /*for (Disease disease : diseases) {
      ranges.put(disease, null);
    }*/
    for (Object[] line : list) {
      Disease        disease = (Disease) line[0];
      DiseaseRange    range = ranges.get(disease);
      boolean        rendered = line[1] != null;
      Date        date = (Date) line[1];
            Collaborator        coll = rendered ? ((CollaboratorFunctions) line[2]).getCollaborator() : null;
      if (disease == null){
        continue;
      }
      if (range == null){
        range = new DiseaseRange();
                if (rendered) {
                    range.begin = date;
                    range.opener = coll;
                    range.end = date;
                    range.closer = coll;
                }
        ranges.put(disease, range);
      }
      else{
        if (rendered){
          if (range.begin == null || range.begin.after(date)){
            range.begin = date;
                        range.opener = coll;
          }
          if (range.end == null || range.end.before(date)){
            range.end = date;
                        range.closer = coll;
          }
        }
      }
    }
    for (Map.Entry<Disease, DiseaseRange> entry : ranges.entrySet()) {
      DiseaseRange        range = entry.getValue();
      Disease            disease = entry.getKey();
            if (range.begin != null) {
                disease.setCreated(range.begin);
                disease.setCollaborator(range.opener);
            }
      if (disease.getCloser() != null){
                /*Дату закрытия не надо выставлять по дате последнего посещения
                 */
        //disease.setClosed(range.end);
                disease.setCloser(range.closer);
      } else {
        //disease.setClosed(null);
      }
            manager.persist(disease);
    }
View Full Code Here

        System.out.println("Подготовка результатов - Начало процесса");
        HashSet<String> target = new HashSet<String>();
        Set<Entry<Integer, Integer>> entrySet = mapDisease.entrySet();
        for (Entry<Integer, Integer> entry : entrySet) {
            if (entry.getValue() != 1) {
                Disease disease = findEntity(Disease.class, entry.getKey());
                target.add(disease.getEmc().getClient().getFio());
            }
        }
        System.out.println("Подготовка результатов - Завершено");
        return target;
    }
View Full Code Here

    @Override
    public ModificationInfo createNewServices(NewServicesChunk chunk) throws ClipsServerException {
        ArrayList<AuditDetails> auditDetList = new ArrayList<AuditDetails>();
        checkCommandAccessibility(COMMAND_CREATE);
        DiscountCard card = null;
        Disease disease = (chunk.diseaseID == 0) ? null : findEntity(Disease.class, chunk.diseaseID);
        //Сооздаем полис если его нет
        Pair<Polis, AuditDetails> pair = getPolis(chunk.polisDetails);
        Polis polis = pair.first;
        if (pair.second != null) {
            auditDetList.add(pair.second);
        }
        Collaborator collaborator = findEntity(Collaborator.class, getCollaboratorId());

        Set<Integer> contractServIDs = new HashSet<Integer>();
        Iterator it = findEntityList(ServicePrice.class, "contract", polis.getContract()).iterator();
        while (it.hasNext()) {
            ServicePrice j = (ServicePrice) it.next();
            contractServIDs.add(j.getService().getId());
        }
               
               
        //build discounts
        HashMap<Integer, Integer> cardDiscounts = new HashMap<Integer, Integer>();
        if (chunk.discountCardID > 0) {
            card = findEntity(DiscountCard.class, chunk.discountCardID);

            for (int i = 0; i < chunk.serviceList.size(); i++) {
                ServiceCheckupChunk checkupChunk = chunk.serviceList.get(i);
                if (chunk.forceDiscountMap.get(checkupChunk.serviceID) == null) {
                    cardDiscounts.put(checkupChunk.serviceID, CalcDiscount.calculateDiscount(manager, chunk.discountCardID, checkupChunk.serviceID, chunk.packetServiceTemplateID));
                }
            }
        }

        PacketService packetService = null;
        Medexam medexam = null;
        //если присутствует пакет
        if (chunk.packetServiceTemplateID != 0) {
            packetService = new PacketService();
            PacketTemplate packetTemplate = findEntity(PacketTemplate.class, chunk.packetServiceTemplateID);
            packetService.setPacketTemplate(packetTemplate);
            saveEntity(packetService);
            MedexamType medexamType = packetTemplate.getMedexamType();
            if (medexamType != null) {
                //не просто пакет, а медосмотр
                if (chunk.diseaseID != 0) {
                    throw new EDataIntegrity("Для медосмотра необходимо создать новое заболевание");
                }
                //создаем заболевание и медосмотр
                disease = new Disease();
                List<Emc> emcList = findEntityList(Emc.class, "client", polis.getClient());
                if (emcList.size() != 1) {
                    throw new EDataIntegrity("У пациента " + emcList.size() + " ЕМК");
                }
                disease.setEmc(emcList.get(0));
                Date current = new Date();
                disease.setCreated(current);
                disease.setDateReg(current);
                disease.setCollaborator(collaborator);
                manager.persist(disease);
                manager.flush();
                manager.refresh(disease);
                chunk.diseaseID = disease.getId();

                medexam = new Medexam();
                medexam.setDisease(disease);
                medexam.setMedexamType(medexamType);
                manager.persist(medexam);
View Full Code Here

    @Override
    public ModificationInfo createNewServices(NewServicesChunk chunk, int referedSerrenIDthrows ClipsServerException {
        ArrayList<AuditDetails> auditDetList = new ArrayList<AuditDetails>();
        checkCommandAccessibility(COMMAND_CREATE);
       
        Disease disease = findEntity(Disease.class, chunk.diseaseID);
        //Создаем полис если его нет
        Pair<Polis, AuditDetails> pair = getPolis(chunk.polisDetails);
        Polis polis = pair.first;
        Contract contract = polis.getContract();
        if (pair.second != null) {
            auditDetList.add(pair.second);
        }
        Collaborator collaborator = findEntity(Collaborator.class, getCollaboratorId());
        if (contract.getLpu() != null && contract.getLpu().getId() != collaborator.getLpu().getId()) {
            throw new EDataIntegrity("Указанный контракт не заключен с данной клиникой");
        }

        for (int i = 0; i < chunk.serviceList.size(); i++) {
           
            ServiceCheckupChunk serviceCheckupChunk = chunk.serviceList.get(i);
            Service s = findEntity(Service.class, serviceCheckupChunk.serviceID);
            ServiceRender referedSerren = findEntity(ServiceRender.class, referedSerrenID);

            AuditDoc<ServiceRender> auditSerren = new AuditDoc<ServiceRender>(null, getCollaborator());
            ServiceRender entity = new ServiceRender();
            entity.setService(s);
            entity.setDate(new Date());
            entity.setDisease(disease);
            entity.setDirector(collaborator);
            entity.setPolis(polis);
            entity.setReferenced(referedSerren);
            entity.setUet(ServiceRender.DEFAULT_UET);
            if (entity.getPolis().getClient().getId() != disease.getEmc().getClient().getId()) {
                throw new EDataIntegrity("Ошибка в коде назначения услуги - полис не соответствует ЭМК");
            }
           
            manager.persist(entity);
View Full Code Here

        //diseaseID;       // - пока пофиг TODO проверка соответствия пациента по полису и ЭМК
        if (serrenDetails.diseaseID == 0) {
            serren.setDisease(null);
        } else {
            Disease disease = findEntity(Disease.class, serrenDetails.diseaseID);
            if (serren.getPolis().getClient().getId() != disease.getEmc().getClient().getId()) {
                throw new EDataIntegrity("Ошибка в коде назначения услуги - полис не соответствует ЕМК");
            }
            serren.setDisease(disease);
        }
View Full Code Here

TOP

Related Classes of beans.doctor.disease.Disease

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.